From f3816a4a964f65893eb7ed92c2a86886f03d9df9 Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Sat, 5 Jul 2025 23:28:01 -0400 Subject: [PATCH] Add reload reading log command to load reading log from file --- src/commands/ReloadReadingLogCommand.ts | 14 ++++++++++++++ src/main.ts | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 src/commands/ReloadReadingLogCommand.ts diff --git a/src/commands/ReloadReadingLogCommand.ts b/src/commands/ReloadReadingLogCommand.ts new file mode 100644 index 0000000..d79ed59 --- /dev/null +++ b/src/commands/ReloadReadingLogCommand.ts @@ -0,0 +1,14 @@ +import type { ReadingLog } from "@utils/ReadingLog"; +import { Command } from "./Command"; +import { Notice } from "obsidian"; + +export class ReloadReadingLogCommand extends Command { + constructor(private readonly readingLog: ReadingLog) { + super("reload-reading-log", "Reload Reading Log From File"); + } + + async callback() { + await this.readingLog.load(); + new Notice("Reading log loaded from file."); + } +} diff --git a/src/main.ts b/src/main.ts index f91c3fb..397aa88 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,6 +23,7 @@ import { RestoreReadingLogBackupCommand } from "@commands/RestoreReadingLogBacku import { Goodreads } from "@data-sources/Goodreads"; import { CreateBookFromGoodreadsUrlCommand } from "@commands/CreateBookFromGoodreadsUrlCommand"; import { registerShelfCodeBlockProcessor } from "@ui/code-blocks/ShelfCodeBlock"; +import { ReloadReadingLogCommand } from "@commands/ReloadReadingLogCommand"; export default class BookTrackerPlugin extends Plugin { public settings: BookTrackerPluginSettings; @@ -81,6 +82,7 @@ export default class BookTrackerPlugin extends Plugin { this.createEntry.bind(this) ) ); + this.addCommand(new ReloadReadingLogCommand(this.readingLog)); this.addSettingTab(new BookTrackerSettingTab(this));