mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
f511fe4fcf
Only request managed status for the assistant addon. Cover the configured attachment path and keep operator-only gateway configuration out of the self-hosted environment reference.
25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
import { useEffect } from 'react';
|
|
|
|
import { useAddonStore } from '../../store/addonStore';
|
|
import { aiRoutesOpen, useAssistantStore } from '../../store/assistantStore';
|
|
import { useAuthStore } from '../../store/authStore';
|
|
|
|
/**
|
|
* Asks for the assistant's status when a view of it mounts, and again when
|
|
* either addon that opens /api/ai is switched: the addon list can land after
|
|
* the view, and an admin can switch either addon while it is open. The
|
|
* assistant's own addon counts on its own, since the status says it runs only
|
|
* while that one is on, even with AI parsing keeping /api/ai open. The store
|
|
* asks the server only while one is on (aiRoutesOpen).
|
|
*/
|
|
export function useAssistantStatus(): void {
|
|
const loadStatus = useAssistantStore((s) => s.loadStatus);
|
|
const managed = useAuthStore((s) => s.managed);
|
|
const routesOpen = useAddonStore((s) => aiRoutesOpen(s, managed));
|
|
const assistantOn = useAddonStore((s) => s.isEnabled('ai_assistant'));
|
|
|
|
useEffect(() => {
|
|
void loadStatus();
|
|
}, [routesOpen, assistantOn, loadStatus]);
|
|
}
|