From ad707a5887b3fbb1094051198b200e7ef9e8e574 Mon Sep 17 00:00:00 2001 From: Rex Cheng Date: Wed, 11 Feb 2026 21:13:03 +0800 Subject: [PATCH] fix: include custom markers in journal entry query conditions When `treatJournalEntriesAsScheduled` is enabled, custom markers like WAITING on journal pages were not displayed because: 1. In today.ts, `journalEntryCond` only matched built-in markers (NOW/LATER/TODO/DOING), so custom markers on journal pages fell through all query conditions. 2. In scheduled.ts, the marker filter excluded custom markers entirely. 3. In next-n-days.ts, custom markers were not handled at all. This fix adds custom markers to the journal entry conditions in all three query files and updates App.tsx to pass the customMarkers parameter to all query functions. Fixes #57 --- src/App.tsx | 5 ++-- src/querys/next-n-days.ts | 48 ++++++++++++++++++++++++++++++++++----- src/querys/scheduled.ts | 10 +++++++- src/querys/today.ts | 13 ++++++++++- 4 files changed, 66 insertions(+), 10 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 06e0b5f..133a319 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -110,7 +110,7 @@ function App() { {settings.showNextNDaysTask && ( )} '"' + m + '"').join(' '); + + const journalMarkerFilter = customMarkers.length > 0 + ? `(or + [(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)] + [(contains? #{${markers}} ?marker)])` + : `[(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)]`; + + const journalEntryCond = treatJournalEntriesAsScheduled ? ` + (and + ${journalMarkerFilter} + [?p :block/journal? true] + [?p :block/journal-day ?d] + (not [?b :block/scheduled]) + (not [?b :block/deadline]) + [(> ?d ${start})] + [(<= ?d ${next})]) + ` : ''; + + const customMarkerScheduledCond = customMarkers.length > 0 ? ` + (and + [(contains? #{${markers}} ?marker)] + (or + [?b :block/scheduled ?d] + [?b :block/deadline ?d]) + [(> ?d ${start})] + [(<= ?d ${next})]) + ` : ''; const query = ` [:find (pull ?b [*]) :where [?b :block/marker ?marker] - [(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)] [?b :block/page ?p] (or - [?b :block/scheduled ?d] - [?b :block/deadline ?d]) - [(> ?d ${start})]] - [(> ?d ${next})]] + (and + [(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)] + (or + [?b :block/scheduled ?d] + [?b :block/deadline ?d]) + [(> ?d ${start})] + [(<= ?d ${next})]) + ${journalEntryCond} + ${customMarkerScheduledCond})] `; return query; } diff --git a/src/querys/scheduled.ts b/src/querys/scheduled.ts index 8f99130..df75c8e 100644 --- a/src/querys/scheduled.ts +++ b/src/querys/scheduled.ts @@ -3,19 +3,27 @@ import dayjs, { Dayjs } from 'dayjs'; export default function getScheduledTaskQuery( treatJournalEntriesAsScheduled = true, startDate: Dayjs | Date = new Date(), + customMarkers: string[] = [], ) { const start = dayjs(startDate).format('YYYYMMDD'); + const markers = customMarkers.map((m) => '"' + m + '"').join(' '); const journalEntryCond = treatJournalEntriesAsScheduled ? ` (and [?p :block/journal? true] [?p :block/journal-day ?d])` : ''; + const markerFilter = customMarkers.length > 0 + ? `(or + [(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)] + [(contains? #{${markers}} ?marker)])` + : `[(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)]`; + const query = ` [:find (pull ?b [*]) :where [?b :block/marker ?marker] - [(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)] + ${markerFilter} [?b :block/page ?p] (or (or diff --git a/src/querys/today.ts b/src/querys/today.ts index 902d5ef..c1352ec 100644 --- a/src/querys/today.ts +++ b/src/querys/today.ts @@ -26,6 +26,16 @@ export default function getTodayTaskQuery( [(<= ?d ${today})]) ` : ''; + const customMarkerJournalCond = customMarkers.length > 0 && treatJournalEntriesAsScheduled ? ` + (and + [(contains? #{${markers}} ?marker)] + [?p :block/journal? true] + [?p :block/journal-day ?d] + (not [?b :block/scheduled]) + (not [?b :block/deadline]) + [(<= ?d ${today})]) + ` : ''; + const query = ` [:find (pull ?b [*]) :where @@ -39,7 +49,8 @@ export default function getTodayTaskQuery( [?b :block/deadline ?d]) [(<= ?d ${today})]) ${journalEntryCond} - ${customMarkerCond})] + ${customMarkerCond} + ${customMarkerJournalCond})] `; return query;