use viaaas prefix for localstorage check navigate mode

This commit is contained in:
creeper123123321 2021-07-01 13:52:43 -03:00
parent aadfba6bd0
commit 1b232ae693
4 changed files with 18 additions and 19 deletions

View File

@ -1,22 +1,22 @@
// Account storage
function storeMcAccount(accessToken, clientToken, name, id, msUser = null) {
let accounts = JSON.parse(localStorage.getItem("mc_accounts")) || [];
let accounts = JSON.parse(localStorage.getItem("viaaas_mc_accounts")) || [];
let account = {accessToken: accessToken, clientToken: clientToken, name: name, id: id, msUser: msUser};
accounts.push(account);
localStorage.setItem("mc_accounts", JSON.stringify(accounts));
localStorage.setItem("viaaas_mc_accounts", JSON.stringify(accounts));
refreshAccountList();
return account;
}
function removeMcAccount(id) {
let accounts = JSON.parse(localStorage.getItem("mc_accounts")) || [];
let accounts = getMcAccounts();
accounts = accounts.filter(it => it.id != id);
localStorage.setItem("mc_accounts", JSON.stringify(accounts));
localStorage.setItem("viaaas_mc_accounts", JSON.stringify(accounts));
refreshAccountList();
}
function getMcAccounts() {
return JSON.parse(localStorage.getItem("mc_accounts")) || [];
return JSON.parse(localStorage.getItem("viaaas_mc_accounts")) || [];
}
function findAccountByMcName(name) {

View File

@ -2,9 +2,9 @@ function defaultCors() {
return "https://crp123-cors.herokuapp.com/";
}
function getCorsProxy() {
return localStorage.getItem("cors-proxy") || defaultCors();
return localStorage.getItem("viaaas_cors_proxy") || defaultCors();
}
function setCorsProxy(url) {
localStorage.setItem("cors-proxy", url);
localStorage.setItem("viaaas_cors_proxy", url);
refreshCorsStatus();
}
}

View File

@ -9,34 +9,32 @@ function defaultWs() {
}
function getWsUrl() {
let url = localStorage.getItem("ws-url") || defaultWs();
localStorage.setItem("ws-url", url);
return url;
return localStorage.getItem("viaaas_ws_url") || defaultWs();
}
function setWsUrl(url) {
localStorage.setItem("ws-url", url);
localStorage.setItem("viaaas_ws_url", url);
location.reload();
}
// Tokens
function saveToken(token) {
let hTokens = JSON.parse(localStorage.getItem("tokens")) || {};
let tokens = hTokens[wsUrl] || [];
let hTokens = JSON.parse(localStorage.getItem("viaaas_tokens")) || {};
let tokens = getTokens();
tokens.push(token);
hTokens[wsUrl] = tokens;
localStorage.setItem("tokens", JSON.stringify(hTokens));
localStorage.setItem("viaaas_tokens", JSON.stringify(hTokens));
}
function removeToken(token) {
let hTokens = JSON.parse(localStorage.getItem("tokens")) || {};
let tokens = hTokens[wsUrl] || [];
let hTokens = JSON.parse(localStorage.getItem("viaaas_tokens")) || {};
let tokens = getTokens();
tokens = tokens.filter(it => it != token);
hTokens[wsUrl] = tokens;
localStorage.setItem("tokens", JSON.stringify(hTokens));
localStorage.setItem("viaaas_tokens", JSON.stringify(hTokens));
}
function getTokens() {
return (JSON.parse(localStorage.getItem("tokens")) || {})[wsUrl] || [];
return (JSON.parse(localStorage.getItem("viaaas_tokens")) || {})[wsUrl] || [];
}
// Websocket

View File

@ -15,6 +15,7 @@ self.addEventListener("install", evt => {
});
self.addEventListener("fetch", evt => {
if (event.request.mode != "navigate") return;
evt.respondWith(
fromNetwork(evt.request)
.catch(() => fromCache(evt.request))