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:
Maurice
2026-10-09 10:39:01 +02:00
parent deff306755
commit 3b4539f600
7 changed files with 105 additions and 47 deletions
@@ -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,
};
}