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" register: "/register"
} }
export const alerts = writable([]) export const alerts = writable([])
export const globals = writable({ export const globalstore = writable({
server: { server: {
url: '', url: '',
caps: { 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 // Most of your app wide CSS should be put in this file
import '../app.postcss'; import '../app.postcss';
import {alerts, globals} from "$lib/stores.js"; import {alerts, globalstore} from "$lib/stores.js";
import { autoModeWatcher } from '@skeletonlabs/skeleton'; import { autoModeWatcher } from '@skeletonlabs/skeleton';
let alertsvar; let alertsvar;
@ -23,7 +23,7 @@
alerts.subscribe((value) => { alerts.subscribe((value) => {
alertsvar = value; alertsvar = value;
}); });
globals.subscribe(value => { globalstore.subscribe(value => {
globalvars = value; globalvars = value;
}); });
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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