From 52fa2ddb0361842caf15ffe1cf99867a87dff369 Mon Sep 17 00:00:00 2001 From: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> Date: Wed, 6 Sep 2023 11:06:30 -0700 Subject: [PATCH] Fix voice message playback and end sound order --- ts/state/smart/VoiceNotesPlaybackProvider.tsx | 17 ++++++++++------- ts/util/Sound.ts | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ts/state/smart/VoiceNotesPlaybackProvider.tsx b/ts/state/smart/VoiceNotesPlaybackProvider.tsx index f2c5b346e61e..d742bfc99386 100644 --- a/ts/state/smart/VoiceNotesPlaybackProvider.tsx +++ b/ts/state/smart/VoiceNotesPlaybackProvider.tsx @@ -12,6 +12,7 @@ import { } from '../ducks/audioPlayer'; import { globalMessageAudio } from '../../services/globalMessageAudio'; import { strictAssert } from '../../util/assert'; +import { drop } from '../../util/drop'; import * as log from '../../logging/log'; import { Sound, SoundType } from '../../util/Sound'; import { getConversations } from '../selectors/conversations'; @@ -20,10 +21,10 @@ import { markViewed } from '../ducks/conversations'; import * as Errors from '../../types/errors'; import { usePrevious } from '../../hooks/usePrevious'; -const stateChangeConfirmUpSound = new Sound({ +const stateChangeConfirmDownSound = new Sound({ soundType: SoundType.VoiceNoteStart, }); -const stateChangeConfirmDownSound = new Sound({ +const stateChangeConfirmUpSound = new Sound({ soundType: SoundType.VoiceNoteEnd, }); @@ -128,10 +129,12 @@ export function SmartVoiceNotesPlaybackProvider( }); if (playNextConsecutiveSound) { - // eslint-disable-next-line more/no-then - void stateChangeConfirmUpSound.play().then(() => { - globalMessageAudio.play(); - }); + drop( + (async () => { + await stateChangeConfirmDownSound.play(); + globalMessageAudio.play(); + })() + ); } else { globalMessageAudio.play(); } @@ -220,7 +223,7 @@ function loadAudio({ }, onEnded() { if (playFinishConsecutiveSound) { - void stateChangeConfirmDownSound.play(); + drop(stateChangeConfirmUpSound.play()); } messageAudioEnded(); }, diff --git a/ts/util/Sound.ts b/ts/util/Sound.ts index c09bde5b2a43..2bc2085b3e59 100644 --- a/ts/util/Sound.ts +++ b/ts/util/Sound.ts @@ -124,11 +124,11 @@ export class Sound { } if (soundStyle === SoundType.VoiceNoteEnd) { - return 'sounds/state-change_confirm-down.ogg'; + return 'sounds/state-change_confirm-up.ogg'; } if (soundStyle === SoundType.VoiceNoteStart) { - return 'sounds/state-change_confirm-up.ogg'; + return 'sounds/state-change_confirm-down.ogg'; } if (soundStyle === SoundType.Whoosh) {