Skip to content

Commit

Permalink
clean comments
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Aug 3, 2024
1 parent 87d104e commit f577d34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/components/ExtraContent/extraContentItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const ExtraContentItem = ({
}, [id])

const loadContent = useCallback(() => {
console.log("Loading content for " + id)
//console.log("Loading content for " + id)
if (isPaused || !visibilityState[id] || !useUiContextFn.panels.isVisible(elementsCache.getRootfromId(id))) return
setIsLoading(true)
if (source.startsWith("http")) {
Expand Down Expand Up @@ -113,16 +113,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){
Expand All @@ -143,13 +143,13 @@ const ExtraContentItem = ({
}

} else {
console.log("Element " + id + " doesn't exist")
console.error("Element " + id + " doesn't exist")
}

}
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`;
Expand All @@ -176,6 +176,7 @@ const ExtraContentItem = ({
}
}, [refreshtime, type, isPaused, loadContent])


const handleError = () => {
setHasError(true)
setIsLoading(false)
Expand Down Expand Up @@ -314,7 +315,6 @@ const ExtraContentItem = ({
)}
</div>
), [type, refreshtime, isPaused, captureImage, togglePause]);
console.log("Rendering :" + "<div id=" + id+ " class='extra-content-container'>")
return (
<div id={id} class="extra-content-container">
<ContainerHelper id={id} />
Expand Down
11 changes: 5 additions & 6 deletions src/components/ExtraContent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ const ExtraContent = ({ id, source, refreshtime, label, type, target, icon }) =>

const updateContentPosition = () => {
if (!useUiContextFn.panels.isVisible(id)) return
console.log("Updating position for element " + extra_content_id, "in target", target_id, " of panel ", id)
//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()
console.log("New Position for element " + extra_content_id + ":", top, left, width, height)
//console.log("New Position for element " + extra_content_id + ":", top, left, width, height)
eventBus.emit('updateState', { id: extra_content_id, position: { top, left, width, height }, isVisible: true, from: "extraContent(position)" })
} else {
console.log("Element " + target_id + " doesn't exist")
console.error("Element " + target_id + " doesn't exist")
}
}

Expand Down Expand Up @@ -83,7 +83,7 @@ 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")
//console.log("Updating element " + extra_content_id + " because it already exists")
updateContentPosition()
}

Expand All @@ -110,8 +110,7 @@ const ExtraContent = ({ id, source, refreshtime, label, type, target, icon }) =>

const handleRefresh = () => {
useUiContextFn.haptic()
console.log("Refreshing element " + extra_content_id)
//eventBus.list()
//console.log("Refreshing element " + extra_content_id)
eventBus.emit('updateState', { id: extra_content_id, isVisible: true, forceRefresh: true, from: "extraContent(refresh)-" + Date.now() })
updateContentPosition()
}
Expand Down
3 changes: 3 additions & 0 deletions src/pages/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ const Dashboard = () => {
} else {
//console.log("Init Done")
}
return () => {
console.log("Unmount dashboard")
}
}, [])

useEffect(() => {
Expand Down

0 comments on commit f577d34

Please sign in to comment.