feat(settings): fetch localStorage at state change

This commit is contained in:
ItzCrazyKns 2024-05-06 12:34:59 +05:30
parent 9b088cd161
commit f28257b480
No known key found for this signature in database
GPG Key ID: 8162927C7CCE3065
1 changed files with 8 additions and 11 deletions

View File

@ -53,15 +53,6 @@ const SettingsDialog = ({
}); });
const data = await res.json(); const data = await res.json();
setConfig(data); setConfig(data);
setIsLoading(false);
};
fetchConfig();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen]);
useEffect(() => {
setSelectedChatModelProvider(localStorage.getItem('chatModelProvider')); setSelectedChatModelProvider(localStorage.getItem('chatModelProvider'));
setSelectedChatModel(localStorage.getItem('chatModel')); setSelectedChatModel(localStorage.getItem('chatModel'));
setSelectedEmbeddingModelProvider( setSelectedEmbeddingModelProvider(
@ -70,7 +61,13 @@ const SettingsDialog = ({
setSelectedEmbeddingModel(localStorage.getItem('embeddingModel')); setSelectedEmbeddingModel(localStorage.getItem('embeddingModel'));
setCustomOpenAIApiKey(localStorage.getItem('openAIApiKey')); setCustomOpenAIApiKey(localStorage.getItem('openAIApiKey'));
setCustomOpenAIBaseURL(localStorage.getItem('openAIBaseUrl')); setCustomOpenAIBaseURL(localStorage.getItem('openAIBaseUrl'));
}, []); setIsLoading(false);
};
fetchConfig();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen]);
const handleSubmit = async () => { const handleSubmit = async () => {
setIsUpdating(true); setIsUpdating(true);