From 9cd27dad6fd8e054637e93492e7c0971067a461d Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:36:54 +1100 Subject: 'localStorage is not defined'? --- assets/client_test/developers.html | 74 ++++++++++++++++---------------- assets/client_test/index.html | 4 +- assets/preload-plugins/checkLocale.js | 12 +----- assets/preload-plugins/fosscord-login.js | 12 ------ assets/preload-plugins/loginRedirect.js | 2 +- 5 files changed, 43 insertions(+), 61 deletions(-) delete mode 100644 assets/preload-plugins/fosscord-login.js diff --git a/assets/client_test/developers.html b/assets/client_test/developers.html index 1673e982..23d0c3f1 100644 --- a/assets/client_test/developers.html +++ b/assets/client_test/developers.html @@ -1,41 +1,43 @@ - - - - - - Discord Test Client Developer Portal - - + + + - -
- - - - - - + +
+ + + + + + + \ No newline at end of file diff --git a/assets/client_test/index.html b/assets/client_test/index.html index da6e2854..f3dbd514 100644 --- a/assets/client_test/index.html +++ b/assets/client_test/index.html @@ -41,8 +41,8 @@ GLOBAL_ENV.MEDIA_PROXY_ENDPOINT = location.protocol + "//" + GLOBAL_ENV.CDN_HOST; // TODO: remote auth // window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); - localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); - localStorage.setItem( + window.localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); + window.localStorage.setItem( "DeveloperOptionsStore", `{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}` ); diff --git a/assets/preload-plugins/checkLocale.js b/assets/preload-plugins/checkLocale.js index 0fbc73ee..1b5e7b71 100644 --- a/assets/preload-plugins/checkLocale.js +++ b/assets/preload-plugins/checkLocale.js @@ -1,11 +1,3 @@ -// TODO: remote auth -// window.GLOBAL_ENV.REMOTE_AUTH_ENDPOINT = window.GLOBAL_ENV.GATEWAY_ENDPOINT.replace(/wss?:/, ""); -localStorage.setItem("gatewayURL", window.GLOBAL_ENV.GATEWAY_ENDPOINT); -localStorage.setItem( - "DeveloperOptionsStore", - `{"trace":false,"canary":false,"logGatewayEvents":true,"logOverlayEvents":true,"logAnalyticsEvents":true,"sourceMapsEnabled":false,"axeEnabled":false}` -); - const supportedLocales = [ "bg", "cs", @@ -38,9 +30,9 @@ const supportedLocales = [ "zh-TW" ]; -const settings = JSON.parse(localStorage.getItem("UserSettingsStore")); +const settings = JSON.parse(window.localStorage.getItem("UserSettingsStore")); if (settings && !supportedLocales.includes(settings.locale)) { // fix client locale wrong and client not loading at all settings.locale = "en-US"; - localStorage.setItem("UserSettingsStore", JSON.stringify(settings)); + window.localStorage.setItem("UserSettingsStore", JSON.stringify(settings)); } \ No newline at end of file diff --git a/assets/preload-plugins/fosscord-login.js b/assets/preload-plugins/fosscord-login.js deleted file mode 100644 index 38f82200..00000000 --- a/assets/preload-plugins/fosscord-login.js +++ /dev/null @@ -1,12 +0,0 @@ -// Remove `` from header when we're not accessing `/login` or `/register` -// fosscord-login.css replaces discord's TOS tooltip with something more fitting for fosscord, which when included in the main app, causes other tooltips -// to be affected, which is potentially unwanted. -// -// This script removes fosscord-login.css when a user reloads the page. From testing, it appears fosscord already properly removes -// fosscord-login.css after login is successful, but not if you reload the page after logging in. This script is to remove fosscord-login.css in -// that specific case. - -var token = JSON.parse(localStorage.getItem("token")); -if (!token && location.pathname !== "/login" && location.pathname !== "/register") { - document.getElementById("logincss").remove(); -} diff --git a/assets/preload-plugins/loginRedirect.js b/assets/preload-plugins/loginRedirect.js index cda4da44..0b5e443a 100644 --- a/assets/preload-plugins/loginRedirect.js +++ b/assets/preload-plugins/loginRedirect.js @@ -1,7 +1,7 @@ if (window.location.hostname !== "127.0.0.1" && window.location.hostname !== "localhost") { const redirectIfOnLogin = () => { const path = window.location.pathname; - if (path == "/login" || path == "/register" || !localStorage.getItem("token")) { + if (path == "/login" || path == "/register" || !window.localStorage.getItem("token")) { window.location.pathname = "/login"; //window.location.reload(); } -- cgit 1.4.1