-
Notifications
You must be signed in to change notification settings - Fork 26
fix: Daily note integration uses meeting date instead of sync date #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -311,8 +311,7 @@ class GranolaSyncPlugin extends obsidian.Plugin { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let syncedCount = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const todaysNotes = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const today = new Date().toDateString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const notesByDate = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (let i = 0; i < documentsToSync.length; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const doc = documentsToSync[i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -327,43 +326,48 @@ class GranolaSyncPlugin extends obsidian.Plugin { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| syncedCount++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check for note integration regardless of sync success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This ensures existing notes from today are still included | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Group notes by their creation date for daily/periodic note integration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ((this.settings.enableDailyNoteIntegration || this.settings.enablePeriodicNoteIntegration) && doc.created_at) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const noteDate = new Date(doc.created_at).toDateString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (noteDate === today) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Find the actual file that was created or already exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const actualFile = await this.findExistingNoteByGranolaId(doc.id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (actualFile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const noteData = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.title = doc.title || 'Untitled Granola Note'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.actualFilePath = actualFile.path; // Use actual file path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createdDate = new Date(doc.created_at); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hours = String(createdDate.getHours()).padStart(2, '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const minutes = String(createdDate.getMinutes()).padStart(2, '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.time = hours + ':' + minutes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| todaysNotes.push(noteData); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createdDate = new Date(doc.created_at); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const dateKey = createdDate.toDateString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Find the actual file that was created or already exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const actualFile = await this.findExistingNoteByGranolaId(doc.id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (actualFile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const noteData = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.title = doc.title || 'Untitled Granola Note'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.actualFilePath = actualFile.path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.date = createdDate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hours = String(createdDate.getHours()).padStart(2, '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const minutes = String(createdDate.getMinutes()).padStart(2, '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| noteData.time = hours + ':' + minutes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!notesByDate[dateKey]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| notesByDate[dateKey] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| notesByDate[dateKey].push(noteData); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+333
to
+351
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const dateKey = createdDate.toDateString(); | |
| // Find the actual file that was created or already exists | |
| const actualFile = await this.findExistingNoteByGranolaId(doc.id); | |
| if (actualFile) { | |
| const noteData = {}; | |
| noteData.title = doc.title || 'Untitled Granola Note'; | |
| noteData.actualFilePath = actualFile.path; | |
| noteData.date = createdDate; | |
| const hours = String(createdDate.getHours()).padStart(2, '0'); | |
| const minutes = String(createdDate.getMinutes()).padStart(2, '0'); | |
| noteData.time = hours + ':' + minutes; | |
| if (!notesByDate[dateKey]) { | |
| notesByDate[dateKey] = []; | |
| } | |
| notesByDate[dateKey].push(noteData); | |
| if (!isNaN(createdDate.getTime())) { | |
| const dateKey = createdDate.toDateString(); | |
| // Find the actual file that was created or already exists | |
| const actualFile = await this.findExistingNoteByGranolaId(doc.id); | |
| if (actualFile) { | |
| const noteData = {}; | |
| noteData.title = doc.title || 'Untitled Granola Note'; | |
| noteData.actualFilePath = actualFile.path; | |
| noteData.date = createdDate; | |
| const hours = String(createdDate.getHours()).padStart(2, '0'); | |
| const minutes = String(createdDate.getMinutes()).padStart(2, '0'); | |
| noteData.time = hours + ':' + minutes; | |
| if (!notesByDate[dateKey]) { | |
| notesByDate[dateKey] = []; | |
| } | |
| notesByDate[dateKey].push(noteData); | |
| } |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a length check before accessing array elements. While the loop over Object.entries(notesByDate) will skip empty objects, and theoretically arrays shouldn't be empty in this structure, defensive programming suggests checking notes.length > 0 before accessing notes[0].date to prevent potential runtime errors.
| for (const [dateKey, notes] of Object.entries(notesByDate)) { | |
| for (const [dateKey, notes] of Object.entries(notesByDate)) { | |
| // Defensive check: ensure there is at least one note before accessing notes[0] | |
| if (!notes || notes.length === 0) { | |
| continue; | |
| } |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment "Let's try to find the daily note directly" is misleading in the getPeriodicNote method. It should say "periodic note" instead of "daily note" to accurately reflect the method's purpose.
| // Let's try to find the daily note directly by looking for it in the vault | |
| // Let's try to find the periodic note directly by looking for it in the vault |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getPeriodicNote method is searching for files in paths containing 'Daily' (lines 1532, 1544-1545), but this should be searching for periodic notes, not daily notes. This appears to be a logic error that would cause the method to look in the wrong location for periodic notes. Consider updating the search logic to look for periodic note patterns or use a more appropriate folder name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential timezone issue: Using
toDateString()as the key (line 333) and then using the same date object for updates may cause issues if meetings are created near midnight. ThetoDateString()method converts to local time, which means a meeting created at 23:59 UTC on Tuesday could appear as Wednesday in some timezones. Consider whether the grouping should use UTC dates or if the current behavior is intentional to match user's local timezone.