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) {
try {
const parsedProviders: Record<string, IProviderSetting> = 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);