fix: do not trigger setInitialized in catch when error occured
This commit is contained in:
@@ -312,20 +312,20 @@ 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 }),
|
||||||
if (sessionRef.current !== session) return;
|
fetchTemplates({ page: -1 })
|
||||||
applyAutoSelection(
|
]);
|
||||||
instanceResItems || [],
|
if (sessionRef.current !== session) return;
|
||||||
templatesRes?.items || [],
|
applyAutoSelection(
|
||||||
orgId
|
instanceResItems || [],
|
||||||
);
|
templatesRes?.items || [],
|
||||||
setInitialized(true);
|
orgId
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
setInitialized(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setInitialized(true);
|
setInitialized(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user