Add reload reading log command to load reading log from file

This commit is contained in:
Evan Fiordeliso 2025-07-05 23:28:01 -04:00
parent a1956078d8
commit f3816a4a96
2 changed files with 16 additions and 0 deletions

View File

@ -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.");
}
}

View File

@ -23,6 +23,7 @@ import { RestoreReadingLogBackupCommand } from "@commands/RestoreReadingLogBacku
import { Goodreads } from "@data-sources/Goodreads"; import { Goodreads } from "@data-sources/Goodreads";
import { CreateBookFromGoodreadsUrlCommand } from "@commands/CreateBookFromGoodreadsUrlCommand"; import { CreateBookFromGoodreadsUrlCommand } from "@commands/CreateBookFromGoodreadsUrlCommand";
import { registerShelfCodeBlockProcessor } from "@ui/code-blocks/ShelfCodeBlock"; import { registerShelfCodeBlockProcessor } from "@ui/code-blocks/ShelfCodeBlock";
import { ReloadReadingLogCommand } from "@commands/ReloadReadingLogCommand";
export default class BookTrackerPlugin extends Plugin { export default class BookTrackerPlugin extends Plugin {
public settings: BookTrackerPluginSettings; public settings: BookTrackerPluginSettings;
@ -81,6 +82,7 @@ export default class BookTrackerPlugin extends Plugin {
this.createEntry.bind(this) this.createEntry.bind(this)
) )
); );
this.addCommand(new ReloadReadingLogCommand(this.readingLog));
this.addSettingTab(new BookTrackerSettingTab(this)); this.addSettingTab(new BookTrackerSettingTab(this));