Procházet zdrojové kódy

fix: drop stale loadingId clear from useAudioPlayer abort branch

The AbortError catch was zeroing loadingId based on the aborted
call's id. In a play(A)→play(B)→play(A) sequence, the first
abort would fire after the third play() set loadingId=A, see
its own id match, and zero a value that belonged to the newer
invocation — making the third play silently no-op.

stop() already clears loadingId synchronously before any new
play(), so the aborted call has nothing to clean up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jimmylee před 2 týdny
rodič
revize
4c266f8ff6

+ 3 - 1
src/views/Editor/EnglishSpeaking/composables/useAudioPlayer.ts

@@ -118,7 +118,9 @@ export function useAudioPlayer(): AudioPlayer {
       // mid-synthesis — that is a normal interrupt, not a failure.
       synthAbort = null
       if (err instanceof Error && err.name === 'AbortError') {
-        if (loadingId.value === id) loadingId.value = null
+        // loadingId was already cleared synchronously by stop(); if a newer
+        // play() has since set it again, that value belongs to that call,
+        // not this aborted one. Do nothing here.
         return
       }
       failPlayback(id, err)