Skip to content

Commit 1cf757d

Browse files
committed
Reduce some logging for b14
1 parent 9d7b940 commit 1cf757d

4 files changed

Lines changed: 26 additions & 25 deletions

File tree

201 KB
Loading

‎jgclark.Dashboard/src/react/components/Dashboard.jsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ const Dashboard = ({ pluginData }: Props): React$Node => {
102102
let workingSections = origSections
103103
if (workingSections.length >= 1 && dashboardSettings?.hideDuplicates) {
104104
// FIXME: this seems to be called for every section, even on refresh when only 1 section is requested
105+
105106
// TB and PROJ sections need to be ignored here, as they have different item types
106107
const dedupedSections = getSectionsWithoutDuplicateLines(origSections.slice(), ['filename', 'content'], sectionPriority, dontDedupeSectionCodes, dashboardSettings)
107108
workingSections = dedupedSections
108109
}
109110

110111
const sortedSections = sortSections(workingSections.slice(), dashboardSettings?.customSectionDisplayOrder || [])
111112
const totalVisibleAfterSort = countTotalVisibleSectionItems(sortedSections, dashboardSettings)
112-
113113
// logDebug('Dashboard:sortSections', `after sort: ${sortedSections.length} (${getDisplayListOfSectionCodes(sortedSections)}) with ${String(countTotalSectionItems(sortedSections, dontDedupeSectionCodes))} items`)
114114

115115
return {
116116
sections: sortedSections,
117117
totalSectionItems: totalVisibleAfterSort,
118118
}
119-
}, [origSections, dashboardSettings])
119+
}, [origSections, dashboardSettings, dashboardSettings?.customSectionDisplayOrder])
120120

121121
const dashboardContainerStyle = {
122122
maxWidth: '100vw',

‎jgclark.Dashboard/src/react/components/Section/Section.jsx‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => {
4848
renderCountRef.current += 1
4949

5050
/**
51-
* Log a diff between previous and current values for easier debugging of rerenders.
51+
* Log a diff between previous and current values for easier debugging of re-renders.
5252
*
5353
* @param {string} label - Identifier for the value being compared.
5454
* @param {any} previousValue - The previous render value.
@@ -68,26 +68,27 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => {
6868
[section.sectionCode, section.name],
6969
)
7070

71-
useEffect(() => {
72-
if (prevPluginDataRef.current !== pluginData) {
73-
const changedKeys = Object.keys(pluginData).filter((key) => {
74-
const prevVal = prevPluginDataRef.current[key]
75-
const currVal = pluginData[key]
76-
// Deep comparison for arrays/objects
77-
if (Array.isArray(prevVal) && Array.isArray(currVal)) {
78-
return prevVal.length !== currVal.length || prevVal.some((item, i) => item !== currVal[i])
79-
}
80-
return prevVal !== currVal
81-
})
82-
if (changedKeys.length > 0) {
83-
logDebug('Section', `- ${section.sectionCode} render #${renderCountRef.current}: pluginData changed keys: ${changedKeys.join(', ')}`)
84-
logDiffForLabel('pluginData', prevPluginDataRef.current, pluginData)
85-
}
86-
prevPluginDataRef.current = pluginData
87-
} else {
88-
logDebug('Section', `- ${section.sectionCode} render #${renderCountRef.current}: NO pluginData change: likely prop/context function reference change`)
89-
}
90-
})
71+
// Note: Turn this back on to show the pluginData changes that trigger re-renders.
72+
// useEffect(() => {
73+
// if (prevPluginDataRef.current !== pluginData) {
74+
// const changedKeys = Object.keys(pluginData).filter((key) => {
75+
// const prevVal = prevPluginDataRef.current[key]
76+
// const currVal = pluginData[key]
77+
// // Deep comparison for arrays/objects
78+
// if (Array.isArray(prevVal) && Array.isArray(currVal)) {
79+
// return prevVal.length !== currVal.length || prevVal.some((item, i) => item !== currVal[i])
80+
// }
81+
// return prevVal !== currVal
82+
// })
83+
// if (changedKeys.length > 0) {
84+
// logDebug('Section', `- ${section.sectionCode} render #${renderCountRef.current}: pluginData changed keys: ${changedKeys.join(', ')}`)
85+
// logDiffForLabel('pluginData', prevPluginDataRef.current, pluginData)
86+
// }
87+
// prevPluginDataRef.current = pluginData
88+
// } else {
89+
// logDebug('Section', `- ${section.sectionCode} render #${renderCountRef.current}: NO pluginData change: likely prop/context function reference change`)
90+
// }
91+
// })
9192

9293
useEffect(() => {
9394
if (prevDashboardSettingsRef.current !== dashboardSettings) {
@@ -141,7 +142,7 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => {
141142

142143
// Watch for changes to currentMaxPriorityFromAllVisibleSections and force re-render. This ensures that when one section updates the global max priority, all other sections will re-render and re-filter their items based on the new priority threshol.
143144
useEffect(() => {
144-
logInfo('Section', `- ${section.sectionCode} ${section.name}: Main useEffect has pluginData changed. currentMaxPriFAVS=${currentMaxPriorityFromAllVisibleSections}`)
145+
logDebug('Section', `- ${section.sectionCode} ${section.name}: Main useEffect has pluginData changed. currentMaxPriFAVS=${currentMaxPriorityFromAllVisibleSections}`)
145146
}, [currentMaxPriorityFromAllVisibleSections, section.sectionCode, section.name])
146147

147148
// This useEffect is responsible for preparing and updating the items in a section whenever the section or dashboard settings change.

‎jgclark.Dashboard/src/reactMain.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ export async function getInitialDataForReactWindow(perspectiveName: string = '',
425425
// get whatever pluginData you want the React window to start with and include it in the object below. This all gets passed to the React window
426426
const pluginData = await getPluginData(dashboardSettings, perspectiveSettings, useDemoData) // Note: the only time this is called.
427427
logDebug('getInitialDataForReactWindow', `lastFullRefresh = ${String(pluginData.lastFullRefresh)}`)
428-
clo(pluginData.dashboardSettings, `getInitialData pluginData.dashboardData`)
428+
// clo(pluginData.dashboardSettings, `getInitialDataForReactWindow pluginData.dashboardData`) // huge!
429429
const ENV_MODE = 'development' /* 'development' helps during development. set to 'production' when ready to release */
430430
const dataToPass: PassedData = {
431431
pluginData,

0 commit comments

Comments
 (0)