refactor(widgets): relocate AI chat button

This commit is contained in:
Elian Doran 2025-12-05 11:53:38 +02:00
parent 83e599f0e9
commit f5f38ca670
No known key found for this signature in database
3 changed files with 15 additions and 19 deletions

View File

@ -1,16 +0,0 @@
import FNote from "../../entities/fnote";
import { useTriliumOptionBool } from "../react/hooks";
import { LaunchBarActionButton, useLauncherIconAndTitle } from "./launch_bar_widgets";
export default function AiChatButton({ launcherNote }: { launcherNote: FNote }) {
const [ aiEnabled ] = useTriliumOptionBool("aiEnabled");
const { icon, title } = useLauncherIconAndTitle(launcherNote);
return aiEnabled && (
<LaunchBarActionButton
icon={icon}
text={title}
triggerCommand="createAiChat"
/>
)
}

View File

@ -8,8 +8,7 @@ import BookmarkButtons from "./BookmarkButtons";
import ProtectedSessionStatusWidget from "./ProtectedSessionStatusWidget";
import SyncStatus from "./SyncStatus";
import HistoryNavigationButton from "./HistoryNavigation";
import { CommandButton, CustomWidget, NoteLauncher, QuickSearchLauncherWidget, ScriptLauncher, TodayLauncher } from "./LauncherDefinitions";
import AiChatButton from "./AiChatButton";
import AiChatButton, { CommandButton, CustomWidget, NoteLauncher, QuickSearchLauncherWidget, ScriptLauncher, TodayLauncher } from "./LauncherDefinitions";
import { useTriliumEvent } from "../react/hooks";
export default function LauncherContainer({ isHorizontalLayout }: { isHorizontalLayout: boolean }) {

View File

@ -1,5 +1,5 @@
import { useContext, useEffect, useMemo, useState } from "preact/hooks";
import { useLegacyWidget, useNoteContext, useNoteLabel, useNoteRelationTarget } from "../react/hooks";
import { useLegacyWidget, useNoteContext, useNoteLabel, useNoteRelationTarget, useTriliumOptionBool } from "../react/hooks";
import { ParentComponent } from "../react/react_utils";
import BasicWidget from "../basic_widget";
import FNote from "../../entities/fnote";
@ -70,6 +70,19 @@ export function ScriptLauncher({ launcherNote }: { launcherNote: FNote }) {
)
}
export default function AiChatButton({ launcherNote }: { launcherNote: FNote }) {
const [ aiEnabled ] = useTriliumOptionBool("aiEnabled");
const { icon, title } = useLauncherIconAndTitle(launcherNote);
return aiEnabled && (
<LaunchBarActionButton
icon={icon}
text={title}
triggerCommand="createAiChat"
/>
)
}
export function TodayLauncher({ launcherNote }: { launcherNote: FNote }) {
return (
<CustomNoteLauncher