mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
refactor(settings): share the integration and plugin tab gating between desktop and phone
The addon flags, the managed install flag and the addon reload of the integrations tab now come from one useIntegrationGates hook, and useSettings hands both shells the plugins tab flag next to the integrations one.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useAddonStore } from '../../store/addonStore';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
|
||||
/**
|
||||
* Which integrations the settings shells offer: the addon flags behind each
|
||||
* integration section, whether any of them is on (the Integrations tab only shows
|
||||
* then), and whether this is a managed install. With `reloadAddons` the addon list
|
||||
* is fetched again on mount, as the integrations tab on both shells does.
|
||||
*/
|
||||
export function useIntegrationGates({ reloadAddons }: { reloadAddons: boolean }) {
|
||||
const { isEnabled: addonEnabled, loadAddons } = useAddonStore();
|
||||
const managed = useAuthStore((s) => s.managed);
|
||||
|
||||
const memoriesEnabled = addonEnabled('memories');
|
||||
const mcpEnabled = addonEnabled('mcp');
|
||||
const airtrailEnabled = addonEnabled('airtrail');
|
||||
const llmEnabled = addonEnabled('llm_parsing');
|
||||
const dawarichEnabled = addonEnabled('dawarich');
|
||||
const hasIntegrations = memoriesEnabled || mcpEnabled || airtrailEnabled || llmEnabled || dawarichEnabled;
|
||||
|
||||
useEffect(() => {
|
||||
if (reloadAddons) loadAddons();
|
||||
}, [loadAddons, reloadAddons]);
|
||||
|
||||
return {
|
||||
memoriesEnabled,
|
||||
mcpEnabled,
|
||||
airtrailEnabled,
|
||||
llmEnabled,
|
||||
dawarichEnabled,
|
||||
hasIntegrations,
|
||||
managed,
|
||||
loadAddons,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user