fix(notifications): move onClose/goto into enhance result callback
onClose() and goto() were firing before the server responded, making it impossible for a fail() response to cancel navigation. Moved them inside the result callback behind a result.type !== 'failure' guard. Updated the $app/forms enhance mock to always invoke the returned async callback with a configurable mockFormResult, and added three tests: - success path calls onClose + goto with the correct deep-link URL - failure path skips onClose and goto - annotationId is appended to the URL when present Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -84,15 +84,17 @@ function handleViewAll() {
|
||||
class="contents"
|
||||
use:enhance={() => {
|
||||
optimisticMarkRead(notification.id);
|
||||
onClose();
|
||||
goto(
|
||||
buildCommentHref(
|
||||
notification.documentId,
|
||||
notification.referenceId,
|
||||
notification.annotationId
|
||||
)
|
||||
);
|
||||
return async ({ update }) => {
|
||||
return async ({ result, update }) => {
|
||||
if (result.type !== 'failure') {
|
||||
onClose();
|
||||
goto(
|
||||
buildCommentHref(
|
||||
notification.documentId,
|
||||
notification.referenceId,
|
||||
notification.annotationId
|
||||
)
|
||||
);
|
||||
}
|
||||
await update({ reset: false, invalidateAll: false });
|
||||
};
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user