mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-15 10:55:27 +01:00
use viaaas prefix for localstorage check navigate mode
This commit is contained in:
parent
aadfba6bd0
commit
1b232ae693
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user