mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Drop dead 'await success' on fire-and-forget catalog-admin actions
CatalogAdminContext exposes savePage / deletePage / saveOffer / createOffer / deleteOffer as void-returning fire-and-forget composer dispatches — they just call SendMessageComposer and let the server push back later. The Offer/Page edit views were 'await action(data); if(success) closeForm()' as if the actions returned Promise<boolean>, but they don't return anything. tsgo flagged the truthiness check on void. Drop the await + truthiness — call the action, then close the form unconditionally. This matches the actual behaviour: closeForm() ran synchronously after the void anyway. A future PR that wants real 'wait for server confirmation' UX should refactor the context to return Promise<boolean> (correlated to the response packet via the pendingActionRef machinery already in place).
This commit is contained in:
@@ -91,9 +91,10 @@ export const CatalogAdminOfferEditView: FC<{}> = () =>
|
||||
orderNumber
|
||||
};
|
||||
|
||||
const success = isNew ? await createOffer(data) : await saveOffer(data);
|
||||
if(isNew) createOffer(data);
|
||||
else saveOffer(data);
|
||||
|
||||
if(success && setEditingOffer) setEditingOffer(null);
|
||||
if(setEditingOffer) setEditingOffer(null);
|
||||
};
|
||||
|
||||
const handleDelete = () =>
|
||||
|
||||
@@ -91,9 +91,9 @@ export const CatalogAdminPageEditView: FC<{}> = () =>
|
||||
parentId: parentNode ? parentNode.pageId : -1,
|
||||
};
|
||||
|
||||
const success = await catalogAdmin.savePage(data);
|
||||
catalogAdmin.savePage(data);
|
||||
|
||||
if(success) closeForm();
|
||||
closeForm();
|
||||
};
|
||||
|
||||
const handleDelete = async () =>
|
||||
@@ -101,9 +101,9 @@ export const CatalogAdminPageEditView: FC<{}> = () =>
|
||||
if(!catalogAdmin?.deletePage || isRoot) return;
|
||||
if(!confirm(LocalizeText('catalog.admin.delete.page.confirm', [ 'name' ], [ targetNode.localization ]))) return;
|
||||
|
||||
const success = await catalogAdmin.deletePage(targetPageId);
|
||||
catalogAdmin.deletePage(targetPageId);
|
||||
|
||||
if(success) closeForm();
|
||||
closeForm();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user