fix: provider menu dropdown fix (ghost providers) (#862)
Some checks are pending
Update Stable Branch / prepare-release (push) Waiting to run

This commit is contained in:
Anirban Kar 2024-12-21 23:31:19 +05:30 committed by GitHub
parent 7295352a98
commit d8943f9474
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,15 +60,18 @@ export function useSettings() {
if (savedProviders) { if (savedProviders) {
try { try {
const parsedProviders: Record<string, IProviderSetting> = JSON.parse(savedProviders); const parsedProviders: Record<string, IProviderSetting> = JSON.parse(savedProviders);
Object.keys(parsedProviders).forEach((provider) => { Object.keys(providers).forEach((provider) => {
const currentProvider = providers[provider]; const currentProviderSettings = parsedProviders[provider];
if (currentProviderSettings) {
providersStore.setKey(provider, { providersStore.setKey(provider, {
...currentProvider, ...providers[provider],
settings: { settings: {
...parsedProviders[provider], ...currentProviderSettings,
enabled: parsedProviders[provider].enabled ?? true, enabled: currentProviderSettings.enabled ?? true,
}, },
}); });
}
}); });
} catch (error) { } catch (error) {
console.error('Failed to parse providers from cookies:', error); console.error('Failed to parse providers from cookies:', error);