Provider settings sheets can remain mounted while hidden, so the old display cache could survive into a different provider. Scope the cache to the active provider identity and remount the sheet when that identity changes.
29 lines
840 B
TypeScript
29 lines
840 B
TypeScript
import { useCallback } from "react";
|
|
import { ProviderDiagnosticSheet } from "@/components/provider-diagnostic-sheet";
|
|
import { useProviderSettingsStore } from "@/stores/provider-settings-store";
|
|
|
|
export function ProviderSettingsHost() {
|
|
const serverId = useProviderSettingsStore((state) => state.serverId);
|
|
const provider = useProviderSettingsStore((state) => state.provider);
|
|
const visible = useProviderSettingsStore((state) => state.visible);
|
|
const close = useProviderSettingsStore((state) => state.close);
|
|
|
|
const handleClose = useCallback(() => {
|
|
close();
|
|
}, [close]);
|
|
|
|
if (!serverId || !provider) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ProviderDiagnosticSheet
|
|
key={`${serverId}:${provider}`}
|
|
provider={provider}
|
|
serverId={serverId}
|
|
visible={visible}
|
|
onClose={handleClose}
|
|
/>
|
|
);
|
|
}
|