From f4c430cc4f16ec945c8e1527522540ac8839c67c Mon Sep 17 00:00:00 2001 From: Michael Seifarth Date: Fri, 25 Oct 2024 19:33:51 +0200 Subject: [PATCH] Fix duplicate entries in journal review plugin (#169) * Fix duplicate entries in journal review plugin Fixes #13 Update the `reduceTimeSpans` function in `src/constants.ts` to filter out duplicate entries when time spans overlap. * Add a helper function `isDuplicateNote` to check for duplicate entries based on note paths. * Modify the `reduceTimeSpans` function to use the `isDuplicateNote` helper function to filter out duplicate notes. * Update the settings description in `src/settingsTab.ts` to inform users about overlapping time spans and potential duplicates. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Kageetai/obsidian-plugin-journal-review/issues/13?shareId=XXXX-XXXX-XXXX-XXXX). * chore: prettier * fix: install and use moment for generateNotes.ts * chore: version * chore: prettier * chore: prettier * fix: don't commit everything from workspace * chore: npm audit fix --- .devcontainer.json | 6 ------ manifest.json | 2 +- package-lock.json | 37 +++++++++++++++++++++++++++++-------- package.json | 3 ++- scripts/generateNotes.ts | 2 +- src/constants.ts | 2 +- versions.json | 3 ++- 7 files changed, 36 insertions(+), 19 deletions(-) delete mode 100644 .devcontainer.json diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index fbf7cdc..0000000 --- a/.devcontainer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "tasks": { - "test": "npm run lint", - "build": "npm run build" - } -} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 4c7e03b..b7288d3 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "journal-review", "name": "Journal Review", - "version": "2.4.4", + "version": "2.5.0", "minAppVersion": "0.15.0", "description": "Review your daily notes on their anniversaries, like \"what happened today last year\".", "author": "Kageetai", diff --git a/package-lock.json b/package-lock.json index c0d916a..4f8dd3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-plugin-journal-review", - "version": "2.4.1", + "version": "2.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-plugin-journal-review", - "version": "2.4.1", + "version": "2.5.0", "license": "MIT", "dependencies": { "obsidian-daily-notes-interface": "^0.9.4", @@ -22,6 +22,7 @@ "eslint": "^9.13.0", "globals": "^15.11.0", "knip": "^5.33.3", + "moment": "^2.30.1", "obsidian": "latest", "prettier": "^3.2.5", "ts-node": "^10.9.2", @@ -2208,9 +2209,9 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "license": "MIT", "dependencies": { @@ -2247,9 +2248,10 @@ } }, "node_modules/moment": { - "version": "2.29.4", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", - "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "dev": true, "license": "MIT", "engines": { "node": "*" @@ -2306,6 +2308,15 @@ "obsidian-daily-notes-interface": "dist/main.js" } }, + "node_modules/obsidian-daily-notes-interface/node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/obsidian-daily-notes-interface/node_modules/obsidian": { "version": "1.6.6", "resolved": "git+ssh://git@github.com/obsidianmd/obsidian-api.git#ea526e2459ad3f188c994862a9b106d94bf0f692", @@ -2325,6 +2336,16 @@ "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", "license": "0BSD" }, + "node_modules/obsidian/node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", diff --git a/package.json b/package.json index 1552ade..46366e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-plugin-journal-review", - "version": "2.4.4", + "version": "2.5.0", "description": "Review your daily notes on their anniversaries, like \"what happened today last year\"\n\n", "main": "main.js", "scripts": { @@ -25,6 +25,7 @@ "eslint": "^9.13.0", "globals": "^15.11.0", "knip": "^5.33.3", + "moment": "^2.30.1", "obsidian": "latest", "prettier": "^3.2.5", "ts-node": "^10.9.2", diff --git a/scripts/generateNotes.ts b/scripts/generateNotes.ts index ef6b9d2..9f36e30 100644 --- a/scripts/generateNotes.ts +++ b/scripts/generateNotes.ts @@ -1,5 +1,5 @@ import { mkdirSync, readFileSync, writeFileSync } from "fs"; -import { moment } from "obsidian"; +import * as moment from "moment"; interface PeriodicNotesSettings { daily: { diff --git a/src/constants.ts b/src/constants.ts index 16efd78..b2d8f5c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -140,7 +140,7 @@ export const reduceTimeSpans = ( notes.filter( (note) => !isDuplicateNote(note, acc[title].notes), ), - ) + ) : notes, }; } diff --git a/versions.json b/versions.json index 7cc67d1..7397317 100644 --- a/versions.json +++ b/versions.json @@ -22,5 +22,6 @@ "2.4.1": "0.15.0", "2.4.2": "0.15.0", "2.4.3": "0.15.0", - "2.4.4": "0.15.0" + "2.4.4": "0.15.0", + "2.5.0": "0.15.0" }