From b3baf10994321228e3d6421e6f6774a16e2bd7a5 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:15:45 +0200 Subject: [PATCH 1/3] 2316: Fixed debug mode --- CHANGELOG.md | 3 +++ src/app.jsx | 20 ++++++++++++-------- src/util/app-storage.js | 10 ---------- src/util/config-loader.js | 1 - 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef40f5c8..656cd602 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. ## Unreleased +- [#135](https://github.com/os2display/display-client/pull/135) + - Fixed cursor being hidden when not in debug mode. + - Moved registration of listeners in useEffect. - [#134](https://github.com/os2display/display-client/pull/134) - Fixed remote loader for touch regions. - [#133](https://github.com/os2display/display-client/pull/133) diff --git a/src/app.jsx b/src/app.jsx index e6ad0d7d..f5478844 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -12,6 +12,7 @@ import releaseService from "./service/release-service"; import tenantService from "./service/tenant-service"; import statusService from "./service/status-service"; import constants from "./util/constants"; +import localStorageKeys from "./util/local-storage-keys.js"; /** * App component. @@ -24,12 +25,11 @@ function App() { const [screen, setScreen] = useState(""); const [bindKey, setBindKey] = useState(null); const [displayFallback, setDisplayFallback] = useState(true); + const [debug, setDebug] = useState(false); const checkLoginTimeoutRef = useRef(null); const contentServiceRef = useRef(null); - const debug = appStorage.getDebug(); - const fallbackImageUrl = appStorage.getFallbackImageUrl(); const fallbackStyle = {}; @@ -189,18 +189,22 @@ function App() { useEffect(() => { logger.info("Mounting App."); + document.addEventListener("keypress", handleKeyboard); + document.addEventListener("screen", screenHandler); + document.addEventListener("reauthenticate", reauthenticateHandler); + document.addEventListener("contentEmpty", contentEmpty); + document.addEventListener("contentNotEmpty", contentNotEmpty); + tokenService.checkToken(); + ConfigLoader.loadConfig().then((config) => { + setDebug(config.debug ?? false); + }); + releaseService.checkForNewRelease().finally(() => { releaseService.setPreviousBootInUrl(); releaseService.startReleaseCheck(); - document.addEventListener("screen", screenHandler); - document.addEventListener("reauthenticate", reauthenticateHandler); - document.addEventListener("contentEmpty", contentEmpty); - document.addEventListener("contentNotEmpty", contentNotEmpty); - document.addEventListener("keypress", handleKeyboard); - checkLogin(); appStorage.setPreviousBoot(new Date().getTime()); diff --git a/src/util/app-storage.js b/src/util/app-storage.js index 1da01e04..97d599a3 100644 --- a/src/util/app-storage.js +++ b/src/util/app-storage.js @@ -114,16 +114,6 @@ class AppStorage { localStorage.setItem(localStorageKeys.API_URL, apiUrl); }; - // Debug - - getDebug = () => { - return localStorage.getItem(localStorageKeys.DEBUG); - }; - - setDebug = (debug) => { - localStorage.setItem(localStorageKeys.DEBUG, debug); - }; - // pBoot - previous boot timestamp getPreviousBoot = () => { diff --git a/src/util/config-loader.js b/src/util/config-loader.js index c700990b..f51213ea 100644 --- a/src/util/config-loader.js +++ b/src/util/config-loader.js @@ -35,7 +35,6 @@ const ConfigLoader = { // Make api endpoint available through localstorage. appStorage.setApiUrl(configData.apiEndpoint); - appStorage.setDebug(configData.debug ?? false); resolve(configData); }) From 308ccfbc35088f882613f0ae988b402ae5c601d1 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:17:44 +0200 Subject: [PATCH 2/3] 2316: Removed DEBUG from local-storage-keys --- src/util/local-storage-keys.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/local-storage-keys.js b/src/util/local-storage-keys.js index d74fdd8f..61ba7117 100644 --- a/src/util/local-storage-keys.js +++ b/src/util/local-storage-keys.js @@ -8,7 +8,6 @@ const localStorageKeys = { REFRESH_TOKEN: 'refreshToken', FALLBACK_IMAGE: 'fallbackImage', API_URL: 'apiUrl', - DEBUG: 'debug', PREVIOUS_BOOT: 'previousBoot', }; From 94b2fe88d4d9cd5eee62c259ebcf9b8136c44148 Mon Sep 17 00:00:00 2001 From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:18:56 +0200 Subject: [PATCH 3/3] 2316: Removed unused import --- src/app.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app.jsx b/src/app.jsx index f5478844..b0923e2d 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -12,7 +12,6 @@ import releaseService from "./service/release-service"; import tenantService from "./service/tenant-service"; import statusService from "./service/status-service"; import constants from "./util/constants"; -import localStorageKeys from "./util/local-storage-keys.js"; /** * App component.