mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-27 19:25:15 +02:00
Merge pull request #1038 from JoeMakuta/fix/narrow-effect-use-lazy-state-init-add-memo
fix : narrow effect, use lazy state init and add memo
This commit is contained in:
commit
25b068f420
7 changed files with 17 additions and 23 deletions
|
|
@ -47,7 +47,7 @@ export function GeneralSettingsManager({ searchSpaceId }: GeneralSettingsManager
|
|||
setName(searchSpace.name || "");
|
||||
setDescription(searchSpace.description || "");
|
||||
}
|
||||
}, [searchSpace]);
|
||||
}, [searchSpace?.name, searchSpace?.description]);
|
||||
|
||||
// Derive hasChanges during render
|
||||
const hasChanges = !!searchSpace && ((searchSpace.name || "") !== name || (searchSpace.description || "") !== description);
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
|
|||
|
||||
const { mutateAsync: updatePreferences } = useAtomValue(updateLLMPreferencesMutationAtom);
|
||||
|
||||
const [assignments, setAssignments] = useState({
|
||||
const [assignments, setAssignments] = useState(() => ({
|
||||
agent_llm_id: preferences.agent_llm_id ?? "",
|
||||
document_summary_llm_id: preferences.document_summary_llm_id ?? "",
|
||||
image_generation_config_id: preferences.image_generation_config_id ?? "",
|
||||
});
|
||||
}));
|
||||
|
||||
const [hasChanges, setHasChanges] = useState(false);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
|
@ -129,7 +129,7 @@ export function LLMRoleManager({ searchSpaceId }: LLMRoleManagerProps) {
|
|||
};
|
||||
setAssignments(newAssignments);
|
||||
setHasChanges(false);
|
||||
}, [preferences]);
|
||||
}, [preferences?.agent_llm_id, preferences?.document_summary_llm_id, preferences?.image_generation_config_id]);
|
||||
|
||||
const handleRoleAssignment = (prefKey: string, configId: string) => {
|
||||
const newAssignments = {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export function PromptConfigManager({ searchSpaceId }: PromptConfigManagerProps)
|
|||
if (searchSpace) {
|
||||
setCustomInstructions(searchSpace.qna_custom_instructions || "");
|
||||
}
|
||||
}, [searchSpace]);
|
||||
}, [searchSpace?.qna_custom_instructions]);
|
||||
|
||||
// Derive hasChanges during render
|
||||
const hasChanges = !!searchSpace && (searchSpace.qna_custom_instructions || "") !== customInstructions;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue