Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1831,15 +1831,22 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
const player = new ContinuousPlayer(state.audioKeys.slice(index), {
generateAudio: ({ audioKey }) =>
actions.FETCH_AUDIO({ audioKey }).then((result) => result.blob),
playAudioBlob: ({ audioBlob, audioKey }) =>
actions.PLAY_AUDIO_BLOB({ audioBlob, audioKey }),
playAudioBlob: ({ audioBlob, audioKey }) => {
if (currentAudioKey !== audioKey) {
mutations.SET_AUDIO_PLAY_START_POINT({ startPoint: undefined });
}
return actions.PLAY_AUDIO_BLOB({ audioBlob, audioKey });
},
});
player.addEventListener("playstart", (e) => {
mutations.SET_ACTIVE_AUDIO_KEY({ audioKey: e.audioKey });
});
player.addEventListener("waitstart", (e) => {
void actions.START_PROGRESS();
mutations.SET_ACTIVE_AUDIO_KEY({ audioKey: e.audioKey });
if (currentAudioKey !== e.audioKey) {
mutations.SET_AUDIO_PLAY_START_POINT({ startPoint: undefined });
}
Comment on lines +1847 to +1849
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic to reset the audio play start point appears in both the playAudioBlob callback and the waitstart event listener. This creates redundancy since playstart (which calls playAudioBlob) always follows waitstart in the event flow. Consider removing the duplicate logic from one of these locations to improve maintainability. The reset in playAudioBlob should be sufficient since it's called whenever audio starts playing.

Suggested change
if (currentAudioKey !== e.audioKey) {
mutations.SET_AUDIO_PLAY_START_POINT({ startPoint: undefined });
}

Copilot uses AI. Check for mistakes.
mutations.SET_AUDIO_NOW_GENERATING({
audioKey: e.audioKey,
nowGenerating: true,
Expand Down
Loading