diff --git a/src/components/ExtraContent/extraContentItem.js b/src/components/ExtraContent/extraContentItem.js index cf8288928..637a3c40e 100644 --- a/src/components/ExtraContent/extraContentItem.js +++ b/src/components/ExtraContent/extraContentItem.js @@ -89,7 +89,7 @@ const ExtraContentItem = ({ console.log(useUiContextFn.panels.isVisible(elementsCache.getRootfromId(id))) } - if (isPaused || !visibilityState[id] || !useUiContextFn.panels.isVisible(elementsCache.getRootfromId(id))) return + if (isPaused || !visibilityState[id] || (target=="panel" && !useUiContextFn.panels.isVisible(elementsCache.getRootfromId(id)))) return setIsLoading(true) if (source.startsWith("http")) { setContentUrl(source) @@ -117,16 +117,16 @@ const ExtraContentItem = ({ const listenerId = `listener_${id}`; const handleUpdateState = (msg) => { if (msg.id == id) { - //console.log(`Received message for ${id} with listener ${listenerId}`, msg); + console.log(`Received message for ${id} with listener ${listenerId}`, msg); const element = document.getElementById(id) if ( 'forceRefresh' in msg && msg.forceRefresh) { - //console.log(`Processing forceRefresh for ${id}`); + console.log(`Processing forceRefresh for ${id}`); loadContent() } if ('isVisible' in msg) { if (element) { - //console.log("Updating visibility for element " + id + " to " + msg.isVisible) + console.log("Updating visibility for element " + id + " to " + msg.isVisible) element.style.display = msg.isVisible ? 'block' : 'none'; //is it the same as the current state? if (visibilityState[id]!= msg.isVisible){ @@ -152,8 +152,8 @@ const ExtraContentItem = ({ } if ('position' in msg) { - //console.log("Updating position for element " + id ) - //console.log(msg.position) + console.log("Updating position for element " + id ) + console.log(msg.position) const element = document.getElementById(id) element.style.top = `${msg.position.top}px`; element.style.left = `${msg.position.left}px`; @@ -164,7 +164,7 @@ const ExtraContentItem = ({ } eventBus.on("updateState", handleUpdateState, listenerId) return () => { - //console.log(`Removing listener ${listenerId} for ${id}`); + console.log(`Removing listener ${listenerId} for ${id}`); //eventBus.off("updateState", handleUpdateState, listenerId) } }, [id, loadContent]) diff --git a/src/components/ExtraContent/index.js b/src/components/ExtraContent/index.js index 5a2a3d999..39e93c7c7 100644 --- a/src/components/ExtraContent/index.js +++ b/src/components/ExtraContent/index.js @@ -43,8 +43,11 @@ const ExtraContent = ({ id, source, refreshtime, label, type, target, icon }) => console.log("Extra Content " + id) const updateContentPosition = () => { - if (!useUiContextFn.panels.isVisible(id)) return - //console.log("Updating position for element " + extra_content_id, "in target", target_id, " of panel ", id) + if (!useUiContextFn.panels.isVisible(id)&& target=="panel") { + console.log("Not updating position for element " + extra_content_id, "in target", target_id, " of panel ", id, " because it is not visible") + return + } + console.log("Updating position for element " + extra_content_id, "in target", target_id, " of panel ", id) const container = document.getElementById(target_id) if (container) { const { top, left, width, height } = container.getBoundingClientRect() @@ -83,8 +86,10 @@ const ExtraContent = ({ id, source, refreshtime, label, type, target, icon }) => if (!elementsCache.has(extra_content_id)) { console.error("Error display element " + extra_content_id, " because it doesn't exist") } else { - //console.log("Updating element " + extra_content_id + " because it already exists") - updateContentPosition() + console.log("Updating element " + extra_content_id + " because it already exists") + if (target=="page"){ + updateContentPosition() + } } const main = document.getElementById("main") diff --git a/src/contexts/UiContext.js b/src/contexts/UiContext.js index 416bb81dc..127ec1ba7 100644 --- a/src/contexts/UiContext.js +++ b/src/contexts/UiContext.js @@ -90,6 +90,8 @@ const UiContextProvider = ({ children }) => { }, [panelsList, panelsOrder]); const isPanelVisible = useCallback((id) => { + console.log("Checking visibility for panel " + id) + console.log(visiblePanelsListRef.current) return visiblePanelsListRef.current.some((element) => element.id == id); }, []);