Add settings hydration state to GeneralSettings.jsx
This commit is contained in:
@@ -92,6 +92,7 @@ export default function GeneralSettings({
|
|||||||
const [isCheckingForUpdates, setIsCheckingForUpdates] = useState(false);
|
const [isCheckingForUpdates, setIsCheckingForUpdates] = useState(false);
|
||||||
const [isPurgingLibraries, setIsPurgingLibraries] = useState(false);
|
const [isPurgingLibraries, setIsPurgingLibraries] = useState(false);
|
||||||
const [libraryPurgeStatus, setLibraryPurgeStatus] = useState({ tone: 'neutral', message: '' });
|
const [libraryPurgeStatus, setLibraryPurgeStatus] = useState({ tone: 'neutral', message: '' });
|
||||||
|
const [settingsHydrated, setSettingsHydrated] = useState(false);
|
||||||
const audioInputSupported = supportsAudioInputCapture();
|
const audioInputSupported = supportsAudioInputCapture();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -125,6 +126,7 @@ export default function GeneralSettings({
|
|||||||
: DEFAULT_AUDIO_INPUT_LANGUAGE
|
: DEFAULT_AUDIO_INPUT_LANGUAGE
|
||||||
);
|
);
|
||||||
setUpdateStatus(status || DEFAULT_UPDATE_STATUS);
|
setUpdateStatus(status || DEFAULT_UPDATE_STATUS);
|
||||||
|
setSettingsHydrated(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -148,6 +150,9 @@ export default function GeneralSettings({
|
|||||||
}, [backendApiUrl, ollamaApiUrl]);
|
}, [backendApiUrl, ollamaApiUrl]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!settingsHydrated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (chatModels.length === 0) {
|
if (chatModels.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,9 +167,12 @@ export default function GeneralSettings({
|
|||||||
if (onModelChange) {
|
if (onModelChange) {
|
||||||
onModelChange(nextModel);
|
onModelChange(nextModel);
|
||||||
}
|
}
|
||||||
}, [chatModels, selectedModel, onModelChange]);
|
}, [chatModels, selectedModel, onModelChange, settingsHydrated]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!settingsHydrated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (visionModels.length === 0) {
|
if (visionModels.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,9 +187,12 @@ export default function GeneralSettings({
|
|||||||
if (onVisionModelChange) {
|
if (onVisionModelChange) {
|
||||||
onVisionModelChange(nextModel);
|
onVisionModelChange(nextModel);
|
||||||
}
|
}
|
||||||
}, [visionModels, visionModel, onVisionModelChange]);
|
}, [visionModels, visionModel, onVisionModelChange, settingsHydrated]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!settingsHydrated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (embedModel) {
|
if (embedModel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -189,9 +200,12 @@ export default function GeneralSettings({
|
|||||||
const nextModel = embeddingModels[0] || DEFAULT_EMBED_MODEL;
|
const nextModel = embeddingModels[0] || DEFAULT_EMBED_MODEL;
|
||||||
setEmbedModel(nextModel);
|
setEmbedModel(nextModel);
|
||||||
window.electronAPI.setSetting(EMBED_MODEL_KEY, nextModel);
|
window.electronAPI.setSetting(EMBED_MODEL_KEY, nextModel);
|
||||||
}, [embeddingModels, embedModel]);
|
}, [embeddingModels, embedModel, settingsHydrated]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!settingsHydrated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (rerankModel) {
|
if (rerankModel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -199,9 +213,12 @@ export default function GeneralSettings({
|
|||||||
const nextModel = embedModel || rerankingModels[0] || DEFAULT_EMBED_MODEL;
|
const nextModel = embedModel || rerankingModels[0] || DEFAULT_EMBED_MODEL;
|
||||||
setRerankModel(nextModel);
|
setRerankModel(nextModel);
|
||||||
window.electronAPI.setSetting(RERANK_MODEL_KEY, nextModel);
|
window.electronAPI.setSetting(RERANK_MODEL_KEY, nextModel);
|
||||||
}, [rerankingModels, rerankModel, embedModel]);
|
}, [rerankingModels, rerankModel, embedModel, settingsHydrated]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!settingsHydrated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (transcriptionModel) {
|
if (transcriptionModel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -212,7 +229,7 @@ export default function GeneralSettings({
|
|||||||
if (onTranscriptionModelChange) {
|
if (onTranscriptionModelChange) {
|
||||||
onTranscriptionModelChange(nextModel);
|
onTranscriptionModelChange(nextModel);
|
||||||
}
|
}
|
||||||
}, [whisperModels, transcriptionModel, onTranscriptionModelChange]);
|
}, [whisperModels, transcriptionModel, onTranscriptionModelChange, settingsHydrated]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!audioInputSupported) {
|
if (!audioInputSupported) {
|
||||||
|
|||||||
Reference in New Issue
Block a user