2025-03-16 23:28:52 +02:00
|
|
|
import type { EventData } from "../../components/app_context.js";
|
2025-03-16 23:22:14 +02:00
|
|
|
import type FNote from "../../entities/fnote.js";
|
2025-03-16 23:28:52 +02:00
|
|
|
import options from "../../services/options.js";
|
2025-03-16 23:22:14 +02:00
|
|
|
import CommandButtonWidget from "./command_button.js";
|
|
|
|
|
2025-03-28 20:01:39 +00:00
|
|
|
export default class AiChatButton extends CommandButtonWidget {
|
2025-03-16 23:22:14 +02:00
|
|
|
|
|
|
|
constructor(note: FNote) {
|
|
|
|
super();
|
|
|
|
|
2025-03-28 20:01:39 +00:00
|
|
|
this.command("createAiChat")
|
2025-03-16 23:22:14 +02:00
|
|
|
.title(() => note.title)
|
|
|
|
.icon(() => note.getIcon())
|
|
|
|
.class("launcher-button");
|
|
|
|
}
|
|
|
|
|
2025-03-16 23:28:52 +02:00
|
|
|
isEnabled() {
|
|
|
|
return options.get("aiEnabled") === "true";
|
|
|
|
}
|
|
|
|
|
|
|
|
entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
|
|
|
|
if (loadResults.isOptionReloaded("aiEnabled")) {
|
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
}
|
2025-03-16 23:22:14 +02:00
|
|
|
}
|