frontend: change storage value naming scheme
This commit is contained in:
parent
144877e682
commit
06e081d785
6 changed files with 15 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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 || {},
|
||||
|
|
|
@ -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}`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue