From d8943f94749e669c591ea3ebc364bb4970a9be0f Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Sat, 21 Dec 2024 23:31:19 +0530 Subject: [PATCH] fix: provider menu dropdown fix (ghost providers) (#862) --- app/lib/hooks/useSettings.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index 68d8f6b..3f55151 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -60,15 +60,18 @@ export function useSettings() { if (savedProviders) { try { const parsedProviders: Record = JSON.parse(savedProviders); - Object.keys(parsedProviders).forEach((provider) => { - const currentProvider = providers[provider]; - providersStore.setKey(provider, { - ...currentProvider, - settings: { - ...parsedProviders[provider], - enabled: parsedProviders[provider].enabled ?? true, - }, - }); + Object.keys(providers).forEach((provider) => { + const currentProviderSettings = parsedProviders[provider]; + + if (currentProviderSettings) { + providersStore.setKey(provider, { + ...providers[provider], + settings: { + ...currentProviderSettings, + enabled: currentProviderSettings.enabled ?? true, + }, + }); + } }); } catch (error) { console.error('Failed to parse providers from cookies:', error);