@@ -2,12 +2,9 @@ import { React, useEffect, useState } from "react";
22import { Button } from "react-bootstrap" ;
33import PropTypes from "prop-types" ;
44import { useTranslation } from "react-i18next" ;
5- import { useDispatch } from "react-redux" ;
65import { useRemoteComponent } from "./remote-component-helper" ;
76import ErrorBoundary from "../../../error-boundary" ;
87import "./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