Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#108](https://github.com/os2display/display-client/pull/108)
Only slides with a loaded template should be rendered.
- [#109](https://github.com/os2display/display-client/pull/109)
Change docker image name from `os2display/os2display-client` to `os2display/display-client` to match image name and repository name

Expand Down
34 changes: 29 additions & 5 deletions src/data-sync/pull-strategy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cloneDeep from 'lodash.clonedeep';
import isPublished from '../util/isPublished';
import * as Logger from '../logger/logger';
import Logger from '../logger/logger';
import localStorageKeys from '../local-storage-keys';

/**
Expand Down Expand Up @@ -61,7 +61,8 @@ class PullStrategy {
});
} catch (err) {
Logger.log('error', `Failed to fetch: ${this.endpoint + path}`);
throw err;

return null;
}

if (response.ok === false) {
Expand Down Expand Up @@ -261,6 +262,11 @@ class PullStrategy {
try {
screen = await this.getPath(screenPath);
} catch (err) {
Logger.log(
'warn',
`Screen (${screenPath}) not loaded. Aborting content update.`
);

return;
}

Expand Down Expand Up @@ -343,7 +349,19 @@ class PullStrategy {
// eslint-disable-next-line no-await-in-loop
const templateData = await this.getPath(templatePath);
slide.templateData = templateData;
fetchedTemplates[templatePath] = templateData;

if (templateData !== null) {
fetchedTemplates[templatePath] = templateData;
}
}

// A slide cannot work without templateData. Mark as invalid.
if (slide.templateData === null) {
Logger.log(
'warn',
`Template (${templatePath}) not loaded for slide with id: ${slide['@id']}`
);
slide.invalid = true;
}

if (slide?.theme !== '') {
Expand All @@ -356,7 +374,10 @@ class PullStrategy {
// eslint-disable-next-line no-await-in-loop
const themeData = await this.getPath(themePath);
slide.themeData = themeData;
fetchedThemes[themePath] = themeData;

if (themeData !== null) {
fetchedThemes[themePath] = themeData;
}
}
}

Expand All @@ -376,7 +397,10 @@ class PullStrategy {
// eslint-disable-next-line no-await-in-loop
const mediaData = await this.getPath(mediaId);
slide.mediaData[mediaId] = mediaData;
fetchedMedia[mediaId] = mediaData;

if (mediaData !== null) {
fetchedMedia[mediaId] = mediaData;
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ function Region({ region }) {
* The event. The data is contained in detail.
*/
function regionContentListener(event) {
setNewSlides([...event.detail.slides]);
const receivedSlides = [...event.detail.slides];

// Filter out invalid slides.
setNewSlides(receivedSlides.filter((slide) => !slide.invalid));
}

// Setup event listener for region content.
Expand Down