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));