优化
This commit is contained in:
@@ -64,7 +64,9 @@ export function useDispatchCommandRecovery(scope: () => string) {
|
||||
try { const sent = await send(snapshot(command)); validateCommandResult(sent, command); command.result = sent }
|
||||
catch (error) {
|
||||
// A later rejection cannot erase an earlier unknown write result.
|
||||
if (!previouslyAttempted && isDefiniteDispatchRejection(error)) command.rejected = true
|
||||
if (!previouslyAttempted && isDefiniteDispatchRejection(error)) {
|
||||
pending.value = null
|
||||
}
|
||||
persist(); throw error
|
||||
}
|
||||
}
|
||||
@@ -75,8 +77,11 @@ export function useDispatchCommandRecovery(scope: () => string) {
|
||||
} finally { busy.value = false }
|
||||
}
|
||||
function discardRejected() {
|
||||
if (busy.value || !pending.value?.rejected) return
|
||||
if (busy.value || pending.value?.rejected !== true) return
|
||||
pending.value = null; persist()
|
||||
}
|
||||
// Older browser records explicitly marked a first-attempt rejection as terminal.
|
||||
// Only that recorded proof permits cleanup; unknown attempts and proven results remain.
|
||||
discardRejected()
|
||||
return { pending, busy, begin, execute, discardRejected }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user