Summary
handleUpdateCompleted (lines 222–261) and handleCreateCompleted (lines 263–296) contain nearly identical conditional logic:
- Check for
errors → delegate to customHandler or setErrorMessage
- Check
isValid === false → set customError
- Else → run
additionalQuery, set link, show notification, call afterSave
Both also share the saveOnPageChange || isSaveClick notification branching and the onSaveClick(false) cleanup.
Suggested approach
- Extract the shared condition tree into a single helper (e.g.
handleMutationCompleted) parameterized by the differences (mutation key, notification verb, link-setting logic).
- Simplify the nested
if/else if/else chain — consider early returns for error/invalid cases to flatten the nesting.
Summary
handleUpdateCompleted(lines 222–261) andhandleCreateCompleted(lines 263–296) contain nearly identical conditional logic:errors→ delegate tocustomHandlerorsetErrorMessageisValid === false→ setcustomErroradditionalQuery, set link, show notification, callafterSaveBoth also share the
saveOnPageChange || isSaveClicknotification branching and theonSaveClick(false)cleanup.Suggested approach
handleMutationCompleted) parameterized by the differences (mutation key, notification verb, link-setting logic).if/else if/elsechain — consider early returns for error/invalid cases to flatten the nesting.