diff --git a/frontend/src/animations.js b/frontend/src/animations.js index 878ab11..16bdeab 100644 --- a/frontend/src/animations.js +++ b/frontend/src/animations.js @@ -2,11 +2,11 @@ import { fade, fly } from "svelte/transition"; import { getItem } from "./storage"; export function maybeFly(...e) { - if (getItem("doAnimations")) + if (getItem("app:behavior:doAnimations")) return fly(...e); } export function maybeFade(...e) { - if (getItem("doAnimations")) + if (getItem("app:behavior:doAnimations")) return fade(...e); } diff --git a/frontend/src/auth.js b/frontend/src/auth.js index 5a37220..1ca4db4 100644 --- a/frontend/src/auth.js +++ b/frontend/src/auth.js @@ -15,12 +15,12 @@ export function useAuthHandlers() { export function authWithToken(token, shouldUpdate=false) { if (shouldUpdate) - setItem("token", token); + setItem("auth:token", token); gateway.init(token); } export function logOut() { - removeItem("token"); + removeItem("auth:token"); gateway.close(); gateway.dispatch(GatewayEventType.BadAuth, -1); } diff --git a/frontend/src/gateway.js b/frontend/src/gateway.js index 3be957f..937edaa 100644 --- a/frontend/src/gateway.js +++ b/frontend/src/gateway.js @@ -54,8 +54,8 @@ export default { this.dispatch(GatewayEventType.BadAuth, 0); return false; } - log(`connecting to gateway - gatewayBase: ${getItem("gatewayBase")}`); - this.ws = new WebSocket(getItem("gatewayBase")); + log(`connecting to gateway - gatewayBase: ${getItem("server:gatewayBase")}`); + this.ws = new WebSocket(getItem("server:gatewayBase")); this.ws.onopen = () => { if (this.reconnectTimeout) { clearTimeout(this.reconnectTimeout); diff --git a/frontend/src/main.js b/frontend/src/main.js index 99d22b9..a6a7562 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -11,7 +11,7 @@ window.__waffle = { init(); initResponsiveHandlers(); useAuthHandlers(); -authWithToken(getItem("token")); +authWithToken(getItem("auth:token")); // Remove loading screen const loadingElement = document.getElementById("pre--loading-screen"); diff --git a/frontend/src/request.js b/frontend/src/request.js index 3994de6..3b7d509 100644 --- a/frontend/src/request.js +++ b/frontend/src/request.js @@ -14,7 +14,7 @@ export default async function(method, endpoint, auth=true, body=null) { } if (auth) { - const token = getItem("token"); + const token = getItem("auth:token"); if (token) { options.headers = { ...options.headers || {}, diff --git a/frontend/src/storage.js b/frontend/src/storage.js index 04245b2..388dde7 100644 --- a/frontend/src/storage.js +++ b/frontend/src/storage.js @@ -1,8 +1,8 @@ const defaults = { - apiBase: `${window.location.origin}/api/v1`, - gatewayBase: `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`, - doAnimations: true, - token: "", + "server:apiBase": `${window.location.origin}/api/v1`, + "server:gatewayBase": `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`, + "auth:token": "", + "app:behavior:doAnimations": true, "loggingSink:Gateway": false, "loggingSink:Store": false }; @@ -37,12 +37,13 @@ export function init() { try { store.set(key, typeof defaultValue === "string" ? override : JSON.parse(override)); } catch (o_O) { - console.warn("[Storage]", `init(): An exception was thrown while parsing the value of key "${key}" from _persistentProvider`, o_O); + console.warn("[Storage]", `init(): An exception was thrown while parsing the value of key "${key}" from persistentProvider. The key "${key}" will be removed from persistentProvider.`, o_O); + persistentProvider.removeItem(key); } } }); } export function apiRoute(fragment) { - return `${getItem("apiBase")}/${fragment}` + return `${getItem("server:apiBase")}/${fragment}` }