Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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

- [#139](https://github.com/os2display/display-client/pull/139)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually PR140

- Fixed issue where campaign end resulted in blank screen.

## [2.1.1] - 2024-10-23

- [#138](https://github.com/os2display/display-client/pull/138)
Expand Down
4 changes: 4 additions & 0 deletions src/components/region.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ function Region({ region }) {

// Setup event listener for region content.
useEffect(() => {
logger.info(`Mounting region ${regionId}`);

document.addEventListener(
`regionContent-${regionId}`,
regionContentListener
);

return function cleanup() {
logger.info(`Unmounting region ${regionId}`);

// Emit event that region has been removed.
const event = new CustomEvent("regionRemoved", {
detail: {
Expand Down
13 changes: 7 additions & 6 deletions src/data-sync/pull-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ class PullStrategy {

const newScreen = cloneDeep(screen);

// Campaigns data
let hasActiveCampaign = false;
newScreen.hasActiveCampaign = false;

const newScreenChecksums = newScreen?.relationsChecksum ?? [];
const oldScreenChecksums =
Expand All @@ -224,13 +223,13 @@ class PullStrategy {
if (newScreen.campaignsData.length > 0) {
newScreen.campaignsData.forEach(({ published }) => {
if (isPublished(published)) {
hasActiveCampaign = true;
newScreen.hasActiveCampaign = true;
}
});
}

// With active campaigns, we override region/layout values.
if (hasActiveCampaign) {
if (newScreen.hasActiveCampaign) {
logger.info(`Has active campaign.`);

// Create ulid to connect the campaign with the regions/playlists.
Expand Down Expand Up @@ -259,8 +258,11 @@ class PullStrategy {
newScreen.regionData
);
} else {
logger.info(`Has no active campaign.`);

// Get layout: Defines layout and regions.
if (
this.lastestScreenData?.hasActiveCampaign ||
oldScreenChecksums === null ||
oldScreenChecksums?.layout !== newScreenChecksums?.layout
) {
Expand All @@ -274,6 +276,7 @@ class PullStrategy {

// Fetch regions playlists: Yields playlists of slides for the regions
if (
this.lastestScreenData?.hasActiveCampaign ||
oldScreenChecksums === null ||
oldScreenChecksums?.regions !== newScreenChecksums?.regions
) {
Expand Down Expand Up @@ -394,8 +397,6 @@ class PullStrategy {
}
/* eslint-enable no-restricted-syntax,no-await-in-loop */

logger.info(`Emitting screen data.`);

this.lastestScreenData = newScreen;

// Deliver result to rendering
Expand Down
3 changes: 3 additions & 0 deletions src/service/schedule-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class ScheduleService {
clearInterval(this.intervals[regionId]);
delete this.intervals[regionId];
}

// Remove cached version of region data.
delete this.regions[regionId];
}

/**
Expand Down
Loading