Skip to content

Commit

Permalink
Merge pull request #135 from os2display/feature/2316-debug-mode
Browse files Browse the repository at this point in the history
Feature/2316 debug mode
  • Loading branch information
tuj authored Sep 26, 2024
2 parents 09eb894 + 94b2fe8 commit 9dfe4a2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 11 additions & 8 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,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 = {};

Expand Down Expand Up @@ -189,18 +188,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());
Expand Down
10 changes: 0 additions & 10 deletions src/util/app-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
1 change: 0 additions & 1 deletion src/util/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const ConfigLoader = {

// Make api endpoint available through localstorage.
appStorage.setApiUrl(configData.apiEndpoint);
appStorage.setDebug(configData.debug ?? false);

resolve(configData);
})
Expand Down
1 change: 0 additions & 1 deletion src/util/local-storage-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const localStorageKeys = {
REFRESH_TOKEN: 'refreshToken',
FALLBACK_IMAGE: 'fallbackImage',
API_URL: 'apiUrl',
DEBUG: 'debug',
PREVIOUS_BOOT: 'previousBoot',
};

Expand Down

0 comments on commit 9dfe4a2

Please sign in to comment.