feat: Update globalstore and sessionstore variable names

- Renamed `globals` to `globalstore` in `stores.js`
- Updated import statements in affected files to reflect the change
This commit is contained in:
Jeroen De Meerleer 2023-08-28 10:15:24 +02:00
parent b4c64c2d3d
commit d0c26770fa
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 28CCCB8F62BFADD6
8 changed files with 32 additions and 33 deletions

View File

@ -8,7 +8,7 @@ export const urls = {
register: "/register"
}
export const alerts = writable([])
export const globals = writable({
export const globalstore = writable({
server: {
url: '',
caps: {
@ -19,4 +19,4 @@ export const globals = writable({
}
});
export const sessionvars = localStorageStore('vars', [], {storage: 'session'})
export const sessionstore = localStorageStore('vars', [], {storage: 'session'})

View File

@ -7,7 +7,7 @@
// Most of your app wide CSS should be put in this file
import '../app.postcss';
import {alerts, globals} from "$lib/stores.js";
import {alerts, globalstore} from "$lib/stores.js";
import { autoModeWatcher } from '@skeletonlabs/skeleton';
let alertsvar;
@ -23,7 +23,7 @@
alerts.subscribe((value) => {
alertsvar = value;
});
globals.subscribe(value => {
globalstore.subscribe(value => {
globalvars = value;
});
</script>

View File

@ -1,9 +1,9 @@
<script>
import {globals} from "$lib/stores.js";
import {globalstore} from "$lib/stores.js";
let globalvars;
globals.subscribe(value => {
globalstore.subscribe(value => {
globalvars = value;
});
</script>

View File

@ -36,7 +36,7 @@
</style>
<script lang="js">
import {alerts, globals} from "$lib/stores.js";
import {alerts, globalstore} from "$lib/stores.js";
let alertsvar;
let globalvars;
@ -52,7 +52,7 @@
alertsvar = value;
});
globals.subscribe(value => {
globalstore.subscribe(value => {
globalvars = value;
});
</script>

View File

@ -8,11 +8,11 @@
<script>
import Server from "./Server.svelte";
import Login from "./Login.svelte";
import {globals} from "$lib/stores.js";
import {globalstore} from "$lib/stores.js";
let globalvars;
globals.subscribe(value => {
globalstore.subscribe(value => {
globalvars = value;
});
</script>

View File

@ -28,8 +28,7 @@
</style>
<script lang="js">
import { urls, alerts, globals, sessionvars } from "$lib/stores.js";
import { browser } from "$app/environment";
import { urls, alerts, globalstore, sessionstore } from "$lib/stores.js";
import { requestor, setBaseUrl } from "../../../serverrequest.js";
import { goto } from "$app/navigation";
@ -38,14 +37,14 @@
let globalvars;
globals.subscribe(value => {
globalstore.subscribe(value => {
globalvars = value;
});
let sessions;
let sessionvars;
sessionvars.subscribe(value => {
sessions = value;
sessionstore.subscribe(value => {
sessionvars = value;
});
setBaseUrl(globalvars.server.url);
@ -61,8 +60,8 @@
throw(message)
}
if(!responsedata.success) return alerts.update(data => [...data, {text: 'Login failed: ' + responsedata.message , class: 'error'}]);
globals.update((globalobj) => ({ ...globalobj, ...{user: responsedata.user }}));
sessions.update((sessionobj) => ({ ...sessionobj, ...{authorization: responsedata.authorization }}));
globalstore.update((globalobj) => ({ ...globalobj, ...{user: responsedata.user }}));
sessionstore.update((sessionobj) => ({ ...sessionobj, ...{authorization: responsedata.authorization }}));
goto('/')
} catch (error) {
return alerts.update(data => [...data, {text: error, class: 'error'}]);
@ -70,9 +69,9 @@
}
function handleGoToServerSelect() {
if(typeof sessions.serverurl !== 'undefined') {
sessionvars.update(data => { delete data.serverurl; return data;});
globals.update((data) => ({ ...data, ...{server: {url: '', caps: {}}} }));
if(typeof sessionstore.serverurl !== 'undefined') {
sessionstore.update(data => { delete data.serverurl; return data;});
globalstore.update((data) => ({ ...data, ...{server: {url: '', caps: {}}} }));
}
}
</script>

View File

@ -16,21 +16,21 @@
</style>
<script lang="js">
import {urls, alerts, globals, sessionvars } from "$lib/stores.js";
import {urls, alerts, globalstore, sessionstore } from "$lib/stores.js";
import {onMount} from 'svelte';
import { requestor, setBaseUrl } from "../../../serverrequest.js";
var loginserver;
let sessions;
let sessionvars;
sessionvars.subscribe(value => {
sessions = value;
sessionstore.subscribe(value => {
sessionvars = value;
});
onMount(() => {
if(typeof sessions.serverurl !== 'undefined') {
loginserver = sessions.serverurl;
if(typeof sessionvars.serverurl !== 'undefined') {
loginserver = sessionvars.serverurl;
handleSelectServer();
}
})
@ -51,8 +51,8 @@
let response = await requestor.get(urls.capabilities);
let caps = JSON.parse(response.data);
if(!caps.login) return alerts.update(data => [...data, {text: loginserver + ' is unavailable for login currently', class: 'error'}]);
globals.update(data => ({ ...data, ...{server: {url: loginserver, caps: caps}}}));
sessionvars.update((sessionobj) => ({ ...sessionobj, ...{serverurl: loginserver }}));
globalstore.update(data => ({ ...data, ...{server: {url: loginserver, caps: caps}}}));
sessionstore.update((data) => ({ ...data, ...{serverurl: loginserver }}));
} catch (error) {
return alerts.update(data => [...data, {text: loginserver + ' is not a Blackbird Chess server', class: 'error'}]);
}

View File

@ -29,7 +29,7 @@
</style>
<script lang="js">
import {alerts, globals, urls} from "$lib/stores.js";
import {alerts, globalstore, urls} from "$lib/stores.js";
import { requestor, setBaseUrl } from "../../../serverrequest.js";
import {onMount} from "svelte";
import {goto} from "$app/navigation";
@ -40,20 +40,20 @@
let password = '';
let password2 = '';
globals.subscribe(value => {
globalstore.subscribe(value => {
globalvars = value;
});
setBaseUrl(globalvars.server.url);
onMount(async () => {
if(globalvars.server.url == '' ) {
if(globalstore.server.url == '' ) {
alerts.update(data => data.filter(alert => alert.type !== 'noregister'));
alerts.update(data => [...data,{text: 'You cannot register without selecting a server', type: 'noregister', class: 'error'}]);
goto('/account/login');
return;
}
if(globalvars.server.caps.register == false ) {
if(globalstore.server.caps.register == false ) {
alerts.update(data => data.filter(alert => alert.type !== 'noregister'));
alerts.update(data => [...data,{text: 'You cannot register on this server', type: 'noregister', class: 'error'}]);
}