WIP: Automatically select previous server
This commit is contained in:
parent
fa9f8d3a83
commit
d43649a4b3
@ -17,12 +17,21 @@
|
||||
|
||||
<script lang="js">
|
||||
import { urls } from "../../../stores.js";
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import {createEventDispatcher, onMount} from 'svelte';
|
||||
import {browser} from "$app/environment";
|
||||
|
||||
export let globals;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
var loginserver;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
onMount(() => {
|
||||
if(sessionStorage.getItem('serverurl') != undefined) {
|
||||
loginserver = sessionStorage.getItem('serverurl');
|
||||
handleSelectServer();
|
||||
}
|
||||
})
|
||||
|
||||
function handleSelectServer() {
|
||||
if(!isValidHttpUrl(loginserver)) {
|
||||
loginserver = 'https://' + loginserver;
|
||||
@ -40,6 +49,9 @@
|
||||
if(!data.login) return dispatch('message', {text: 'This server is unavailable for login currently'})
|
||||
globals.server.url = loginserver;
|
||||
globals.server.caps = data;
|
||||
if(browser) {
|
||||
sessionStorage.setItem('serverurl', loginserver);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
return dispatch('message', {text: 'This server is not a Blackbird Chess server'})
|
||||
|
Loading…
Reference in New Issue
Block a user