diff --git a/src/commands/LogReadingFinishedCommand.ts b/src/commands/LogReadingFinishedCommand.ts index e9a9663..b590a09 100644 --- a/src/commands/LogReadingFinishedCommand.ts +++ b/src/commands/LogReadingFinishedCommand.ts @@ -70,6 +70,14 @@ export class LogReadingFinishedCommand extends EditorCheckCommand { } }); + if (this.settings.organizeReadBooks) { + // @ts-expect-error Moment is provided by Obsidian + const datePath = moment().format("YYYY/MMMM"); + const newPath = `${this.settings.readBooksFolder}/${datePath}/${file.name}`; + + await this.app.vault.rename(file, newPath); + } + new Notice("Reading finished for " + fileName); } } diff --git a/src/ui/settings/BookTrackerSettingTabView.svelte b/src/ui/settings/BookTrackerSettingTabView.svelte index bafa44f..654e049 100644 --- a/src/ui/settings/BookTrackerSettingTabView.svelte +++ b/src/ui/settings/BookTrackerSettingTabView.svelte @@ -25,7 +25,7 @@
-
+
+ + - diff --git a/src/ui/settings/types.ts b/src/ui/settings/types.ts index 982a930..07d2597 100644 --- a/src/ui/settings/types.ts +++ b/src/ui/settings/types.ts @@ -1,8 +1,9 @@ export interface BookTrackerSettings { bookFolder: string; + tbrFolder: string; + readBooksFolder: string; organizeReadBooks: boolean; templateFile: string; - tbrFolder: string; fileNameFormat: string; downloadCovers: boolean; coverFolder: string; @@ -18,9 +19,10 @@ export interface BookTrackerSettings { export const DEFAULT_SETTINGS: BookTrackerSettings = { bookFolder: "books", + tbrFolder: "books/tbr", + readBooksFolder: "books/read", organizeReadBooks: true, templateFile: "", - tbrFolder: "books/tbr", fileNameFormat: "{{title}} - {{authors}}", downloadCovers: false, coverFolder: "images/covers",