Skip to content

Commit 331c088

Browse files
committed
Stop Project List generating when its window isn't open. Added more logging around this.
1 parent 4813510 commit 331c088

File tree

9 files changed

+121
-66
lines changed

9 files changed

+121
-66
lines changed

helpers/NPnote.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,6 @@ export function findNotesMatchingHashtagOrMentionFromList(
10971097
})
10981098
}
10991099
if (projectNotesWithItem.length > 0) {
1100-
// logDebug('NPnote/findNotesMatchingHashtagOrMentionFromList',`In folder '${folder ?? '<all>'}' found ${projectNotesWithItem.length} notes matching '${tag}': [${String(projectNotesWithItem.map((a) => a.title ?? a.filename ?? '?'))}]`)
11011100
logDebug('NPnote/findNotesMatchingHashtagOrMentionFromList', `In folder '${folder ?? '<all>'}' found ${projectNotesWithItem.length} notes matching '${item}'`)
11021101
}
11031102

jgclark.Dashboard/CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ For more details see the [plugin's documentation](https://github.com/NotePlan/pl
1010
- TODO: enlarged default window size on iPads
1111
-->
1212

13-
## [2.3.0.b9] 2025-08-???
14-
- Added tagCache age to section info (if 'comparison' is turned on)
13+
## [2.3.0.b9] 2025-09-01
14+
- Added tagCache age to section info (if 'Comparison' FFlag is turned on)
1515
- Add another check to regenerate or update tagMentionCache after 24 and 1 hour respectively
1616
- Make 'Show folder name in note link?' setting indented under 'Show note link for tasks?'
17+
- I have stopped some of the unnecessary generation of Project List. Let me know how it goes, @dwertheimer. (Will require rebuilding jgclark.Reviews plugin as well (to v1.2.4).)
18+
- Also added some logging to track down when Project list generation is happening when it shouldn't be. If 'Show Section Timings' Flag is on, then it will also write a log to note "@Meta/Project Generation Log".
19+
- Fix color of blockID marker in light mode themes
20+
- Further fix to display of calendar events in tasks
21+
- Tweak some TaskDialog button labels
1722

1823
## [2.3.0.b8] 2025-08-27
1924
- Add temporary workaround for error in DataStore.listOverdueParagraphs() for regular Teamspace notes

jgclark.Dashboard/src/dataGeneration.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function getSomeSectionsData(
7979
useEditorWherePossible: boolean,
8080
): Promise<Array<TSection>> {
8181
try {
82-
logDebug('getSomeSectionsData', `🔹Starting with ${sectionCodesToGet.toString()} ...`)
82+
logDebug('getSomeSectionsData', `🔹 Starting with ${sectionCodesToGet.toString()} ...`)
8383
const config: TDashboardSettings = await getDashboardSettings()
8484

8585
const sections: Array<TSection> = []
@@ -94,6 +94,7 @@ export async function getSomeSectionsData(
9494
if (sectionCodesToGet.includes('Q') && config.showQuarterSection) sections.push(...getThisQuarterSectionData(config, useDemoData, useEditorWherePossible))
9595
// moderately quick to generate
9696
if (sectionCodesToGet.includes('PROJ') && config.showProjectSection) {
97+
logInfo('getSomeSectionsData', `🔹 Getting Project section data as part of ${sectionCodesToGet.toString()}`)
9798
const projectSection = await getProjectSectionData(config, useDemoData)
9899
if (projectSection) sections.push(projectSection)
99100
}

jgclark.Dashboard/src/dataGenerationProjects.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
//-----------------------------------------------------------------------------
33
// Generate Project section data
4-
// Last updated 2025-05-16 for v2.3.0
4+
// Last updated 2025-09-01 for v2.3.0
55
//-----------------------------------------------------------------------------
66

77
import { getNextProjectsToReview } from '../../jgclark.Reviews/src/allProjectsListHelpers'
@@ -13,6 +13,8 @@ import type { TDashboardSettings, TSection, TSectionItem } from './types'
1313
import { logDebug, logTimer, timer } from '@helpers/dev'
1414
import { getFolderFromFilename } from '@helpers/folders'
1515
import { pluginIsInstalled } from '@helpers/NPConfiguration'
16+
import { getOrMakeRegularNoteInFolder } from '@helpers/NPnote'
17+
import { smartPrependPara } from '@helpers/paragraph'
1618

1719
/**
1820
* Make a Section for all projects ready for review, using data written by the Projects + Reviews plugin: getNextProjectsToReview().
@@ -67,17 +69,8 @@ export async function getProjectSectionData(config: TDashboardSettings, useDemoD
6769
return null
6870
}
6971
// Get all projects to review (and apply maxProjectsToShow limit later)
70-
// nextProjectsToReview = await getNextProjectsToReview(maxProjectsToShow)
72+
// Note: Perspective filtering is done in P+R (since it was added in v1.1)
7173
nextProjectsToReview = await getNextProjectsToReview()
72-
73-
// add basic filtering by folder for the current Perspective
74-
// const filteredProjects = nextProjectsToReview.filter((p) => {
75-
// const folder = getFolderFromFilename(p.filename)
76-
// return allowedFolders.includes(folder)
77-
// })
78-
// For P+R v1.1 and later, Perspectives can be used, so this filtering is not needed.
79-
// if (filteredProjects) {
80-
// filteredProjects.map((p) => {
8174
if (nextProjectsToReview) {
8275
nextProjectsToReview.map((p) => {
8376
const thisID = `${sectionNumStr}-${itemCount}`
@@ -130,5 +123,13 @@ export async function getProjectSectionData(config: TDashboardSettings, useDemoD
130123
}
131124
// console.log(JSON.stringify(section))
132125
logTimer('getProjectSectionData', thisStartTime, `found ${itemCount} items for ${thisSectionCode}`, 1000)
126+
127+
// Log the start of the generation to a special log note, if we're running. TODO: remove this later.
128+
if (config?.FFlag_ShowSectionTimings) {
129+
const logNote: TNote = await getOrMakeRegularNoteInFolder('Project Generation Log', '@Meta')
130+
const newLogLine = `${new Date().toLocaleString()}: Dashboard -> ${nextProjectsToReview.length} Project(s) ready to review, in ${timer(thisStartTime)}`
131+
smartPrependPara(logNote, newLogLine, 'list')
132+
}
133+
133134
return section
134135
}

jgclark.Dashboard/src/perspectiveHelpers.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//-----------------------------------------------------------------------------
77

88
import pluginJson from '../plugin.json'
9-
// import { generateProjectListsAndRenderIfOpen } from '../../jgclark.Reviews/src/reviews.js'
9+
// import { generateProjectListsAndRenderIfOpen, renderProjectListsIfOpen } from '../../jgclark.Reviews/src/reviews.js' // produces circular dependency
1010
import { getDashboardSettings, getOpenItemParasForTimePeriod, setPluginData } from './dashboardHelpers.js'
1111
import { dashboardSettingsDefaults } from './react/support/settingsHelpers'
1212
import { getTagSectionDetails, showSectionSettingItems } from './react/components/Section/sectionHelpers'
@@ -17,14 +17,14 @@ import { updateTagMentionCacheDefinitionsFromAllPerspectives } from './tagMentio
1717
import type { TDashboardSettings, TDashboardPluginSettings, TPerspectiveDef } from './types'
1818
import { stringListOrArrayToArray } from '@helpers/dataManipulation'
1919
import { getPeriodOfNPDateStr } from '@helpers/dateTime'
20-
import { clo, clof, clvt, JSP, logDebug, logError, logInfo, logWarn } from '@helpers/dev'
20+
import { clo, clof, clvt, JSP, logDebug, logError, logInfo, logTimer, logWarn } from '@helpers/dev'
2121
import { getFolderFromFilename, getFoldersMatching } from '@helpers/folders'
2222
import { displayTitle } from '@helpers/general'
2323
import { allNotesSortedByChanged, getNoteByFilename } from '@helpers/note'
2424
import { chooseNoteV2 } from '@helpers/NPnote'
2525
import { getSettings, saveSettings } from '@helpers/NPConfiguration'
26+
import { isHTMLWindowOpen } from '@helpers/NPWindows'
2627
import { chooseOption, getInputTrimmed, showMessage } from '@helpers/userInput'
27-
2828
export type TPerspectiveOptionObject = { isModified?: boolean, label: string, value: string }
2929

3030
/* -----------------------------------------------------------------------------
@@ -469,6 +469,7 @@ export async function logPerspectiveFiltering(filenameArg?: string): Promise<voi
469469
*/
470470
export async function switchToPerspective(name: string, allDefs: Array<TPerspectiveDef>): Promise<Array<TPerspectiveDef> | false> {
471471
try {
472+
const startTime = new Date()
472473
// Check if perspective exists
473474
logDebug('switchToPerspective', `Starting looking for name ${name} in ...`)
474475
// logPerspectives(allDefs)
@@ -507,10 +508,20 @@ export async function switchToPerspective(name: string, allDefs: Array<TPerspect
507508
// )
508509

509510
// Send message to Reviews (if that window is open) to re-generate the Projects list and render it
510-
// TEST: Now not await-ing this, because it can take a long time and we don't want to block the main thread. FIXME: still taking a long time, and appears to be blocking the main thread.
511-
logDebug('switchToPerspective', `Sending message to Reviews to regenerate the Projects List and render it`)
512-
const _promise = DataStore.invokePluginCommandByName('generateProjectListsAndRenderIfOpen', 'jgclark.Reviews', [])
511+
// TEST: Now not await-ing this, because it can take a long time and we don't want to block the main thread.
512+
// FIXME: Even so, is still taking a long time, and appears to be blocking the main thread.
513+
// logTimer('switchToPerspective', startTime, `Sending message to Reviews to regenerate the Projects List and render it.`)
514+
// const _promise = DataStore.invokePluginCommandByName('generateProjectListsAndRenderIfOpen', 'jgclark.Reviews', [])
513515
// const _promise = generateProjectListsAndRenderIfOpen()
516+
// logTimer('switchToPerspective', startTime, `Sending message to Reviews to regenerate the Projects List and render it.`)
517+
518+
// v3: Work out whether Project list window is open, and if so, re-render it
519+
if (isHTMLWindowOpen('jgclark.Reviews.rich-review-list')) {
520+
// TEST: still not convinced that this is firing and forgetting. At least we're not doing anything if the Project List window is not open.
521+
logTimer('switchToPerspective', startTime, `Sending message to Reviews to render project list as it is open.`)
522+
const _promise = DataStore.invokePluginCommandByName('renderProjectListsIfOpen', 'jgclark.Reviews', [])
523+
logTimer('switchToPerspective', startTime, `Sent message to Reviews`) // Note: never seems to get here
524+
}
514525

515526
return newPerspectiveSettings
516527
} catch (error) {

jgclark.Reviews/plugin.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"plugin.author": "Jonathan Clark",
99
"plugin.url": "https://github.com/NotePlan/plugins/tree/main/jgclark.Reviews",
1010
"plugin.changelog": "https://github.com/NotePlan/plugins/blob/main/jgclark.Reviews/CHANGELOG.md",
11-
"plugin.version": "1.2.3",
12-
"plugin.lastUpdateInfo": "1.2.3: bug fixes.\n.1.2.2: fix bug with 'Finish + Next' review.\n1.2.1: small improvements and bug fixes and under-the-hood changes for integration with Dashboard plugin.\n1.2.0: new settings that affect how plugin calculates % completion for a project.\n1.1.2: fix bug with 'next action' setting.\n1.1.1: turn off background refresh of Dashboard plugin after every change to Project List, as it was causing problems.\n1.1.0: new option to use current 'Perspective' from the Dashboard plugin. New simpler top bar. Other small improvements and fixes.\n1.0.2: theme font size can now be overriden by user setting in NP.\n1.0.1: fix bug with 'next action' setting.\n1.0.0: new 'next action' functionality. New display toggles, and keyboard shortcuts. Much faster. Bug fixes. Lots of under-the-hood changes.\n0.14.1: new 'Remove due dates when pausing a project?' option. Other small improvements and fixes.\n0.14.0: add edit buttons to Rich output. Other small improvements and fixes.\n0.13.2: clarified the 'include' and 'exclude' folder settings. Fixed bug about project notes in root folder always displaying.\n0.13.1: change review list to show 'due' not just 'overdue' (i.e. include items ready to review today.)",
11+
"plugin.version": "1.2.4",
12+
"plugin.lastUpdateInfo": "1.2.4: TEST: to try and fix things in Dashboard.\n1.2.3: bug fixes.\n.1.2.2: fix bug with 'Finish + Next' review.\n1.2.1: small improvements and bug fixes and under-the-hood changes for integration with Dashboard plugin.\n1.2.0: new settings that affect how plugin calculates % completion for a project.\n1.1.2: fix bug with 'next action' setting.\n1.1.1: turn off background refresh of Dashboard plugin after every change to Project List, as it was causing problems.\n1.1.0: new option to use current 'Perspective' from the Dashboard plugin. New simpler top bar. Other small improvements and fixes.\n1.0.2: theme font size can now be overriden by user setting in NP.\n1.0.1: fix bug with 'next action' setting.\n1.0.0: new 'next action' functionality. New display toggles, and keyboard shortcuts. Much faster. Bug fixes. Lots of under-the-hood changes.\n0.14.1: new 'Remove due dates when pausing a project?' option. Other small improvements and fixes.\n0.14.0: add edit buttons to Rich output. Other small improvements and fixes.\n0.13.2: clarified the 'include' and 'exclude' folder settings. Fixed bug about project notes in root folder always displaying.\n0.13.1: change review list to show 'due' not just 'overdue' (i.e. include items ready to review today.)",
1313
"plugin.dependsOn": [
1414
{
1515
"id": "np.Shared",
@@ -208,9 +208,20 @@
208208
},
209209
{
210210
"hidden": true,
211-
"name": "test:renderProjectLists",
211+
"name": "renderProjectLists",
212212
"description": "render current allProjects list in current style(s)",
213-
"jsFunction": "renderProjectLists"
213+
"jsFunction": "renderProjectLists",
214+
"arguments": [
215+
"config",
216+
"shouldOpen window/note if not already open? (optional, default: true)",
217+
"scroll position to set (pixels) for HTML display (optional, default: 0)"
218+
]
219+
},
220+
{
221+
"hidden": true,
222+
"name": "renderProjectListsIfOpen",
223+
"description": "render current allProjects list in current style(s) if already open",
224+
"jsFunction": "renderProjectListsIfOpen"
214225
}
215226
],
216227
"plugin.inactiveCommands": [

0 commit comments

Comments
 (0)