From 52efa857af93ef13fb3bc51b4909c3540aa05d51 Mon Sep 17 00:00:00 2001 From: dralkh Date: Wed, 24 Sep 2025 16:28:21 +0300 Subject: [PATCH] feat(review): combine due notes and today-only notes in default view --- controllers/review-controller-core.ts | 22 +++++++++++++++++++++- main.js | 22 ++++++++++++++++------ ui/calendar-view.ts | 7 +------ 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/controllers/review-controller-core.ts b/controllers/review-controller-core.ts index 2e5527c..7bc53e5 100644 --- a/controllers/review-controller-core.ts +++ b/controllers/review-controller-core.ts @@ -138,7 +138,27 @@ export class ReviewControllerCore implements IReviewController { // If currentReviewDateOverride is set, we are viewing a specific date from the calendar, so match exactly. // Otherwise (override is null), we are in the default "today" view, so get all notes due up to today. const matchExactDate = this.currentReviewDateOverride !== null; - const newDueNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, matchExactDate); + + let newDueNotes: ReviewSchedule[]; + + if (matchExactDate) { + // Calendar view: Get notes for the specific date + newDueNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, true); + } else { + // Default view: Get notes due up to today AND notes for today's date + const dueNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, false); + const todayOnlyNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, true); + + const combinedNotes = [...dueNotes, ...todayOnlyNotes]; + const uniqueNotes = new Map(); + for (const note of combinedNotes) { + if (!uniqueNotes.has(note.path)) { + uniqueNotes.set(note.path, note); + } + } + newDueNotes = Array.from(uniqueNotes.values()); + } + this.todayNotes = newDueNotes; // The traversal order should directly reflect the order of todayNotes, diff --git a/main.js b/main.js index 67c07e1..5683bd8 100644 --- a/main.js +++ b/main.js @@ -1342,7 +1342,21 @@ var ReviewControllerCore = class { const originalPositions = new Map(this.traversalPositions); const effectiveDate = this.getEffectiveReviewDate(); const matchExactDate = this.currentReviewDateOverride !== null; - const newDueNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, matchExactDate); + let newDueNotes; + if (matchExactDate) { + newDueNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, true); + } else { + const dueNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, false); + const todayOnlyNotes = this.plugin.dataStorage.reviewScheduleService.getDueNotesWithCustomOrder(effectiveDate, true, true); + const combinedNotes = [...dueNotes, ...todayOnlyNotes]; + const uniqueNotes = /* @__PURE__ */ new Map(); + for (const note of combinedNotes) { + if (!uniqueNotes.has(note.path)) { + uniqueNotes.set(note.path, note); + } + } + newDueNotes = Array.from(uniqueNotes.values()); + } this.todayNotes = newDueNotes; this.traversalOrder = this.todayNotes.map((note) => note.path); this.traversalPositions = /* @__PURE__ */ new Map(); @@ -5942,11 +5956,7 @@ var CalendarView = class { const today = /* @__PURE__ */ new Date(); const isClickedDateToday = DateUtils.isSameDay(currentDateObj, today); this.plugin.settings.sidebarViewType = "list"; - if (isClickedDateToday) { - this.plugin.clickedDateFromCalendar = null; - } else { - this.plugin.clickedDateFromCalendar = currentDateObj; - } + this.plugin.clickedDateFromCalendar = currentDateObj; await this.plugin.savePluginData(); const sidebarView = this.plugin.getSidebarView(); if (sidebarView && typeof sidebarView.refresh === "function") { diff --git a/ui/calendar-view.ts b/ui/calendar-view.ts index 15ba661..daf01c4 100644 --- a/ui/calendar-view.ts +++ b/ui/calendar-view.ts @@ -221,12 +221,7 @@ export class CalendarView { const isClickedDateToday = DateUtils.isSameDay(currentDateObj, today); this.plugin.settings.sidebarViewType = 'list'; - - if (isClickedDateToday) { - this.plugin.clickedDateFromCalendar = null; - } else { - this.plugin.clickedDateFromCalendar = currentDateObj; - } + this.plugin.clickedDateFromCalendar = currentDateObj; await this.plugin.savePluginData(); const sidebarView = this.plugin.getSidebarView();