mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 02:02:29 +08:00
27 lines
751 B
TypeScript
27 lines
751 B
TypeScript
import type { EventData } from "../../components/app_context.js";
|
|
import type FNote from "../../entities/fnote.js";
|
|
import options from "../../services/options.js";
|
|
import CommandButtonWidget from "./command_button.js";
|
|
|
|
export default class AiChatButton extends CommandButtonWidget {
|
|
|
|
constructor(note: FNote) {
|
|
super();
|
|
|
|
this.command("createAiChat")
|
|
.title(() => note.title)
|
|
.icon(() => note.getIcon())
|
|
.class("launcher-button");
|
|
}
|
|
|
|
isEnabled() {
|
|
return options.get("aiEnabled") === "true";
|
|
}
|
|
|
|
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
|
if (loadResults.isOptionReloaded("aiEnabled")) {
|
|
this.refresh();
|
|
}
|
|
}
|
|
}
|