From 3047ea786a0517b4edf423e2d3e144165099e054 Mon Sep 17 00:00:00 2001
From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com>
Date: Fri, 17 May 2024 09:40:32 +0200
Subject: [PATCH 1/2] 1453: Avoid null redirect when release.json cannot be
retrieved
---
CHANGELOG.md | 6 ++++++
src/app.js | 59 ++++++++++++++++++++++++++++++++++++----------------
src/index.js | 6 +-----
3 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca40573b..88f65a9a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
+## Unreleased
+
+- [#125](https://github.com/os2display/display-client/pull/125)
+ - Removed React strict mode.
+ - Added null check to release query parameter changes, to avoid redirecting to ?releaseVersion=null&releaseTimestamp=null when release.json cannot be reached (eg. when the internet connection is down).
+
## [2.0.2] - 2024-04-25
- [#123](https://github.com/os2display/display-client/pull/123)
diff --git a/src/app.js b/src/app.js
index f978ec1f..f34547b1 100644
--- a/src/app.js
+++ b/src/app.js
@@ -279,18 +279,31 @@ function App() {
const checkForUpdates = () => {
Logger.log('info', 'Checking for new release timestamp.');
- ReleaseLoader.loadConfig().then((config) => {
+ ReleaseLoader.loadConfig().then((release) => {
if (releaseTimestampRef?.current === null) {
- releaseTimestampRef.current = config.releaseTimestamp;
- } else if (releaseTimestampRef?.current !== config.releaseTimestamp) {
- const redirectUrl = new URL(window.location.href);
- redirectUrl.searchParams.set(
- 'releaseTimestamp',
- config.releaseTimestamp
- );
- redirectUrl.searchParams.set('releaseVersion', config.releaseVersion);
-
- window.location.replace(redirectUrl);
+ releaseTimestampRef.current = release.releaseTimestamp;
+ } else if (releaseTimestampRef?.current !== release.releaseTimestamp) {
+ if (
+ release.releaseTimestamp !== null &&
+ release.releaseVersion !== null
+ ) {
+ const redirectUrl = new URL(window.location.href);
+ redirectUrl.searchParams.set(
+ 'releaseTimestamp',
+ release.releaseTimestamp
+ );
+ redirectUrl.searchParams.set(
+ 'releaseVersion',
+ release.releaseVersion
+ );
+
+ window.location.replace(redirectUrl);
+ } else {
+ Logger.log(
+ 'info',
+ 'Release timestamp or version null, not redirecting.'
+ );
+ }
}
});
};
@@ -322,13 +335,23 @@ function App() {
!currentUrl.searchParams.has('releaseTimestamp')
) {
ReleaseLoader.loadConfig().then((release) => {
- currentUrl.searchParams.set(
- 'releaseTimestamp',
- release.releaseTimestamp
- );
- currentUrl.searchParams.set('releaseVersion', release.releaseVersion);
-
- window.history.replaceState(null, '', currentUrl);
+ if (
+ release.releaseTimestamp !== null &&
+ release.releaseVersion !== null
+ ) {
+ currentUrl.searchParams.set(
+ 'releaseTimestamp',
+ release.releaseTimestamp
+ );
+ currentUrl.searchParams.set('releaseVersion', release.releaseVersion);
+
+ window.history.replaceState(null, '', currentUrl);
+ } else {
+ Logger.log(
+ 'info',
+ 'Release timestamp or version null, not setting query parameters.'
+ );
+ }
});
}
diff --git a/src/index.js b/src/index.js
index 8a693779..2de46332 100644
--- a/src/index.js
+++ b/src/index.js
@@ -5,8 +5,4 @@ import App from './app';
const container = document.getElementById('root');
const root = createRoot(container);
-root.render(
-
-
-
-);
+root.render();
From 3475df7e90b4bad3b0385b204f2595cfb5493ff0 Mon Sep 17 00:00:00 2001
From: Troels Ugilt Jensen <6103205+tuj@users.noreply.github.com>
Date: Tue, 21 May 2024 10:19:54 +0200
Subject: [PATCH 2/2] 1453: Updated changelog
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88f65a9a..862111d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
## Unreleased
+## [2.0.3] - 2024-05-21
+
- [#125](https://github.com/os2display/display-client/pull/125)
- Removed React strict mode.
- Added null check to release query parameter changes, to avoid redirecting to ?releaseVersion=null&releaseTimestamp=null when release.json cannot be reached (eg. when the internet connection is down).