Skip to content

Commit 8930b44

Browse files
committed
Merge branch 'release/2.0.1'
2 parents a5637f8 + 68c8e37 commit 8930b44

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [2.0.1] - 2024-04-10
8+
9+
- [#241](https://github.com/os2display/display-admin-client/pull/241)
10+
- Fixed loading of theme for slide preview.
11+
712
## [2.0.0] - 2024-04-09
813

914
- [#240](https://github.com/os2display/display-admin-client/pull/240)

src/components/slide/preview/remote-component-wrapper.jsx

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import { React, useEffect, useState } from "react";
22
import { Button } from "react-bootstrap";
33
import PropTypes from "prop-types";
44
import { useTranslation } from "react-i18next";
5-
import { useDispatch } from "react-redux";
65
import { useRemoteComponent } from "./remote-component-helper";
76
import ErrorBoundary from "../../../error-boundary";
87
import "./remote-component-wrapper.scss";
9-
import { api } from "../../../redux/api/api.generated.ts";
10-
import idFromUrl from "../../util/helpers/id-from-url";
118

129
/**
1310
* A remote component wrapper
@@ -37,8 +34,6 @@ function RemoteComponentWrapper({
3734
const [remoteComponentSlide, setRemoteComponentSlide] = useState(null);
3835
const [loading, err, Component] = useRemoteComponent(url);
3936
const [runId, setRunId] = useState("");
40-
const dispatch = useDispatch();
41-
const [loadedLogos, setLoadedLogos] = useState({});
4237

4338
/** Create remoteComponentSlide from slide and mediaData */
4439
useEffect(() => {
@@ -49,7 +44,7 @@ function RemoteComponentWrapper({
4944
if (mediaData) {
5045
newSlide.mediaData = mediaData;
5146

52-
// Map temp images so they are visible in preview before save
47+
// Map temp images, so they are visible in preview before save
5348
const mediaDataCopy = { ...mediaData };
5449

5550
// Find tempid keys
@@ -67,38 +62,18 @@ function RemoteComponentWrapper({
6762
newSlide.mediaData = mediaDataCopy;
6863
}
6964

70-
newSlide.themeData = themeData;
65+
newSlide.theme = themeData;
7166

7267
// Load theme logo.
7368
if (newSlide?.themeData?.logo) {
74-
if (
75-
Object.prototype.hasOwnProperty.call(
76-
loadedLogos,
77-
newSlide.themeData.logo
78-
)
79-
) {
80-
newSlide.mediaData[newSlide.themeData.logo] =
81-
loadedLogos[newSlide.themeData.logo];
82-
} else {
83-
const key = newSlide.themeData.logo;
84-
85-
dispatch(
86-
api.endpoints.getv2MediaById.initiate({
87-
id: idFromUrl(newSlide.themeData.logo),
88-
})
89-
).then((resp) => {
90-
if (resp.isSuccess) {
91-
const newLoadedLogos = { ...loadedLogos };
92-
newLoadedLogos[key] = resp.data;
93-
setLoadedLogos(newLoadedLogos);
94-
}
95-
});
96-
}
69+
const { logo } = newSlide.themeData;
70+
const logoId = logo["@id"] ?? null;
71+
newSlide.mediaData[logoId] = newSlide?.themeData.logo;
9772
}
9873

9974
setRemoteComponentSlide(newSlide);
10075
}
101-
}, [slide, mediaData, themeData, loadedLogos]);
76+
}, [slide, mediaData, themeData]);
10277

10378
useEffect(() => {
10479
if (showPreview) {

0 commit comments

Comments
 (0)