Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed May 21, 2024
2 parents 68991fe + 3475df7 commit 9c9917c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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).

## [2.0.2] - 2024-04-25

- [#123](https://github.com/os2display/display-client/pull/123)
Expand Down
59 changes: 41 additions & 18 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
}
}
});
};
Expand Down Expand Up @@ -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.'
);
}
});
}

Expand Down
6 changes: 1 addition & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ import App from './app';
const container = document.getElementById('root');
const root = createRoot(container);

root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
root.render(<App />);

0 comments on commit 9c9917c

Please sign in to comment.