diff --git a/jgclark.Dashboard/src/dataGeneration.js b/jgclark.Dashboard/src/dataGeneration.js index e546bbfa6..4587d1bca 100644 --- a/jgclark.Dashboard/src/dataGeneration.js +++ b/jgclark.Dashboard/src/dataGeneration.js @@ -301,22 +301,20 @@ export function getThisMonthSectionData(config: TDashboardSettings, useDemoData: } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>This Month', - showSettingName: 'showMonthSection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${dateStr}`, - FAIconClass: 'fa-light fa-calendar-range', - sectionTitleColorPart: 'sidebarMonthly', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>This Month', + showSettingName: 'showMonthSection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${dateStr}`, + FAIconClass: 'fa-light fa-calendar-range', + sectionTitleColorPart: 'sidebarMonthly', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), + actionButtons: [], } + sections.push(section) } logTimer('getDataForDashboard', startTime, `- found ${itemCount} monthly items from ${thisFilename}`) @@ -498,22 +496,20 @@ export function getThisQuarterSectionData(config: TDashboardSettings, useDemoDat } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>This Quarter', - showSettingName: 'showQuarterSection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${dateStr}`, - FAIconClass: 'fa-light fa-calendar-days', - sectionTitleColorPart: 'sidebarQuarterly', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>This Quarter', + showSettingName: 'showQuarterSection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${dateStr}`, + FAIconClass: 'fa-light fa-calendar-days', + sectionTitleColorPart: 'sidebarQuarterly', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), + actionButtons: [], } + sections.push(section) } logDebug('getDataForDashboard', `- found ${itemCount} quarterly items from ${dateStr} in ${timer(startTime)}`) diff --git a/jgclark.Dashboard/src/dataGenerationDays.js b/jgclark.Dashboard/src/dataGenerationDays.js index 065cca36b..c1dbc9206 100644 --- a/jgclark.Dashboard/src/dataGenerationDays.js +++ b/jgclark.Dashboard/src/dataGenerationDays.js @@ -6,13 +6,7 @@ import moment from 'moment/min/moment-with-locales' import pluginJson from '../plugin.json' -import type { - TDashboardSettings, - TParagraphForDashboard, - TSection, - TSectionItem, - TSettingItem, -} from './types' +import type { TDashboardSettings, TParagraphForDashboard, TSection, TSectionItem, TSettingItem } from './types' import { getNumCompletedTasksTodayFromNote } from './countDoneTasks' import { createSectionItemObject, @@ -23,18 +17,13 @@ import { makeDashboardParas, } from './dashboardHelpers' import { openTodayItems, refTodayItems, openTomorrowParas, refTomorrowParas, openYesterdayParas, refYesterdayParas } from './demoData' -import { - getTodaysDateHyphenated, getTodaysDateUnhyphenated, -} from '@helpers/dateTime' +import { getTodaysDateHyphenated, getTodaysDateUnhyphenated } from '@helpers/dateTime' import { clo, JSP, logDebug, logError, logInfo, logTimer, logWarn, timer } from '@helpers/dev' import { toNPLocaleDateString } from '@helpers/NPdateTime' -import { - getHeadingsFromNote, -} from '@helpers/NPnote' +import { getHeadingsFromNote } from '@helpers/NPnote' import { getCurrentTimeBlockPara, getTimeBlockDetails, isActiveOrFutureTimeBlockPara } from '@helpers/timeblocks' import { isOpen } from '@helpers/utils' - //-------------------------------------------------------------------- /** * Get open items from Today's note @@ -241,22 +230,20 @@ export function getTodaySectionData(config: TDashboardSettings, useDemoData: boo } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>Today', - showSettingName: 'showTodaySection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${todayDateLocale}`, - FAIconClass: 'fa-light fa-calendar-star', - sectionTitleColorPart: 'sidebarDaily', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), // Note: this often gets stringified to a string, but isn't underneath - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>Today', + showSettingName: 'showTodaySection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${todayDateLocale}`, + FAIconClass: 'fa-light fa-calendar-star', + sectionTitleColorPart: 'sidebarDaily', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), // Note: this often gets stringified to a string, but isn't underneath + actionButtons: [], } + sections.push(section) } logTimer('getTodaySectionData', timer, `- found ${itemCount} daily items from ${filenameDateStr}`) @@ -286,24 +273,22 @@ export function getTodaySectionData(config: TDashboardSettings, useDemoData: boo } } - if (timeBlockItems.length > 0) { - const section: TSection = { - ID: TBsectionNumStr, - sectionCode: 'TB', - name: 'Current time block', - showSettingName: 'showTimeBlockSection', - description: '', - FAIconClass: 'fa-light fa-calendar-clock', - sectionTitleColorPart: 'sidebarYearly', - sectionFilename: thisFilename, - sectionItems: timeBlockItems, - generatedDate: new Date(), - actionButtons: [], - } - clo(section) - logTimer('getTodaySectionData', timer, `- found ${String(timeBlockItems.length)} timeblock items from ${filenameDateStr}`) - sections.push(section) + const section: TSection = { + ID: TBsectionNumStr, + sectionCode: 'TB', + name: 'Current time block', + showSettingName: 'showTimeBlockSection', + description: '', + FAIconClass: 'fa-light fa-calendar-clock', + sectionTitleColorPart: 'sidebarYearly', + sectionFilename: thisFilename, + sectionItems: timeBlockItems, + generatedDate: new Date(), + actionButtons: [], } + clo(section) + logTimer('getTodaySectionData', timer, `- found ${String(timeBlockItems.length)} timeblock items from ${filenameDateStr}`) + sections.push(section) } return sections @@ -434,22 +419,20 @@ export function getYesterdaySectionData(config: TDashboardSettings, useDemoData: } } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>Yesterday', - showSettingName: 'showYesterdaySection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${yesterdayDateLocale}`, - FAIconClass: 'fa-light fa-calendar-star', - sectionTitleColorPart: 'sidebarDaily', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>Yesterday', + showSettingName: 'showYesterdaySection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${yesterdayDateLocale}`, + FAIconClass: 'fa-light fa-calendar-star', + sectionTitleColorPart: 'sidebarDaily', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), + actionButtons: [], } + sections.push(section) } logTimer('getDataForDashboard', startTime, `- found ${itemCount} yesterday items from ${filenameDateStr}`) @@ -574,22 +557,20 @@ export function getTomorrowSectionData(config: TDashboardSettings, useDemoData: } } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>Tomorrow', - showSettingName: 'showTomorrowSection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${tomorrowDateLocale}`, - FAIconClass: 'fa-light fa-calendar-arrow-down', - sectionTitleColorPart: 'sidebarDaily', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>Tomorrow', + showSettingName: 'showTomorrowSection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${tomorrowDateLocale}`, + FAIconClass: 'fa-light fa-calendar-arrow-down', + sectionTitleColorPart: 'sidebarDaily', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), + actionButtons: [], } + sections.push(section) } logDebug('getDataForDashboard', `- found ${itemCount} Tomorrow items from ${filenameDateStr} in ${timer(startTime)}`) diff --git a/jgclark.Dashboard/src/dataGenerationWeeks.js b/jgclark.Dashboard/src/dataGenerationWeeks.js index 3fcb7c1f8..dc97e3906 100644 --- a/jgclark.Dashboard/src/dataGenerationWeeks.js +++ b/jgclark.Dashboard/src/dataGenerationWeeks.js @@ -15,10 +15,7 @@ import { // createSectionItemObject, } from './dashboardHelpers' import { openWeekParas, refWeekParas } from './demoData' -import { - getDateStringFromCalendarFilename, - getNPWeekStr, -} from '@helpers/dateTime' +import { getDateStringFromCalendarFilename, getNPWeekStr } from '@helpers/dateTime' import { clo, JSP, logDebug, logError, logInfo, logTimer, logWarn, timer } from '@helpers/dev' import { getHeadingsFromNote } from '@helpers/NPnote' @@ -219,22 +216,20 @@ export function getThisWeekSectionData(config: TDashboardSettings, useDemoData: } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>This Week', - showSettingName: 'showWeekSection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${dateStr}`, - FAIconClass: 'fa-light fa-calendar-week', - sectionTitleColorPart: 'sidebarWeekly', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>This Week', + showSettingName: 'showWeekSection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${dateStr}`, + FAIconClass: 'fa-light fa-calendar-week', + sectionTitleColorPart: 'sidebarWeekly', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), + actionButtons: [], } + sections.push(section) } logDebug('getDataForDashboard', `- found ${itemCount} weekly items from ${dateStr} in ${timer(startTime)}`) @@ -351,22 +346,20 @@ export function getLastWeekSectionData(config: TDashboardSettings, useDemoData: } // Add separate section (if there are any items found) - if (items.length > 0) { - const section: TSection = { - ID: sectionNumStr, - name: '>Last Week', - showSettingName: 'showWeekSection', - sectionCode: thisSectionCode, - description: `{count} scheduled to ${dateStr}`, - FAIconClass: 'fa-light fa-calendar-week', - sectionTitleColorPart: 'sidebarWeekly', - sectionFilename: thisFilename, - sectionItems: items, - generatedDate: new Date(), - actionButtons: [], - } - sections.push(section) + const section: TSection = { + ID: sectionNumStr, + name: '>Last Week', + showSettingName: 'showWeekSection', + sectionCode: thisSectionCode, + description: `{count} scheduled to ${dateStr}`, + FAIconClass: 'fa-light fa-calendar-week', + sectionTitleColorPart: 'sidebarWeekly', + sectionFilename: thisFilename, + sectionItems: items, + generatedDate: new Date(), + actionButtons: [], } + sections.push(section) } logDebug('getLastWeekSectionData', `- found ${itemCount} weekly items from ${thisFilename} in ${timer(startTime)}`) diff --git a/jgclark.Dashboard/src/react/components/Section/Section.jsx b/jgclark.Dashboard/src/react/components/Section/Section.jsx index 510c6386d..0f1e53e38 100644 --- a/jgclark.Dashboard/src/react/components/Section/Section.jsx +++ b/jgclark.Dashboard/src/react/components/Section/Section.jsx @@ -98,12 +98,18 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => { setItems(sectionItems) }, [section, dashboardSettings]) + const refresh = useCallback(() => { + logDebug('Section/TBTimer', `Refreshing section ${section.sectionCode}...`) + const detailsMessageObject = { actionType: 'refreshSomeSections', sectionCodes: ['TB'] } + sendActionToPlugin(detailsMessageObject.actionType, detailsMessageObject, 'TBTimer fired refreshSomeSections', true) + }, [section.sectionCode, sendActionToPlugin]) + /** * Set a timer to refresh the TB section every 1 minute. - * FIXME(dwerteimer): this is what Cursor added on my second attempt -- just trying to keep it all in this file. But doesn't work. + * FIXME(dwertheimer): this is what Cursor added on my second attempt -- just trying to keep it all in this file. But doesn't work. */ useEffect(() => { - const refreshInterval = 60000 // 1 minute + const refreshInterval = 50000 // A little less than 1 minute -- don't want it to collide with the IdleTimer if possible let timerId if (section.sectionCode === 'TB') { @@ -119,14 +125,7 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => { logDebug('Section/TBTimer', `Section ${section.sectionCode} timer cleared`) } } - }, [section.sectionCode]) - - const refresh = useCallback(() => { - logDebug('Section/TBTimer', 'Refreshing section ${section.sectionCode}...') - // TEST: Add your refresh logic here - const detailsMessageObject = { actionType: 'refreshSomeSections', sectionCodes: ['TB'] } - sendActionToPlugin(detailsMessageObject.actionType, detailsMessageObject, 'TBTimer fired refreshSomeSections', true) - }, []) + }, [section.sectionCode, refresh]) //---------------------------------------------------------------------- // Hooks