fix: do not trigger setInitialized in catch when error occured

This commit is contained in:
jialin
2026-06-14 19:14:18 +08:00
committed by jialin
parent 3e2133753d
commit ed3e779d22
@@ -312,11 +312,13 @@ const AddModal: React.FC<AddModalProps> = ({
// The query hook cancels any in-flight request on each new call, so when // The query hook cancels any in-flight request on each new call, so when
// this runs twice in quick succession (drawer open, then the scope // this runs twice in quick succession (drawer open, then the scope
// picker settling on its default) the latest scope's result wins. // picker settling on its default) the latest scope's result wins.
const loadCreateResources = (orgId?: number | null) => { const loadCreateResources = async (orgId?: number | null) => {
const session = ++sessionRef.current; const session = ++sessionRef.current;
try { try {
Promise.all([fetchData({ page: -1 }), fetchTemplates({ page: -1 })]).then( const [instanceResItems, templatesRes] = await Promise.all([
([instanceResItems, templatesRes]) => { fetchData({ page: -1 }),
fetchTemplates({ page: -1 })
]);
if (sessionRef.current !== session) return; if (sessionRef.current !== session) return;
applyAutoSelection( applyAutoSelection(
instanceResItems || [], instanceResItems || [],
@@ -324,8 +326,6 @@ const AddModal: React.FC<AddModalProps> = ({
orgId orgId
); );
setInitialized(true); setInitialized(true);
}
);
} catch (error) { } catch (error) {
setInitialized(true); setInitialized(true);
} }