diff --git a/sounds/pop.ogg b/sounds/pop.ogg new file mode 100644 index 000000000000..f63f9a25386a Binary files /dev/null and b/sounds/pop.ogg differ diff --git a/sounds/pop.wav b/sounds/pop.wav deleted file mode 100644 index 6bca62445a59..000000000000 Binary files a/sounds/pop.wav and /dev/null differ diff --git a/sounds/whoosh.ogg b/sounds/whoosh.ogg new file mode 100644 index 000000000000..e0ac9748a5f1 Binary files /dev/null and b/sounds/whoosh.ogg differ diff --git a/sounds/whoosh.wav b/sounds/whoosh.wav deleted file mode 100644 index 68ea8a3ca52f..000000000000 Binary files a/sounds/whoosh.wav and /dev/null differ diff --git a/ts/state/ducks/composer.ts b/ts/state/ducks/composer.ts index e65326276247..80492a6f74e1 100644 --- a/ts/state/ducks/composer.ts +++ b/ts/state/ducks/composer.ts @@ -618,7 +618,9 @@ function sendMultiMediaMessage( dispatch(incrementSendCounter(conversationId)); dispatch(setComposerDisabledState(conversationId, false)); - drop(new Sound({ soundType: SoundType.Whoosh }).play()); + if (state.items.audioMessage) { + drop(new Sound({ soundType: SoundType.Whoosh }).play()); + } }, } ); diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index d4512150b02e..1e8ea02a2f61 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -160,6 +160,7 @@ import { } from './composer'; import { ReceiptType } from '../../types/Receipt'; import { sortByMessageOrder } from '../../util/maybeForwardMessages'; +import { Sound, SoundType } from '../../util/Sound'; // State @@ -2769,16 +2770,30 @@ function messagesAdded({ isJustSent: boolean; isNewMessage: boolean; messages: ReadonlyArray; -}): MessagesAddedActionType { - return { - type: 'MESSAGES_ADDED', - payload: { - conversationId, - isActive, - isJustSent, - isNewMessage, - messages, - }, +}): ThunkAction { + return (dispatch, getState) => { + const state = getState(); + if ( + isNewMessage && + state.items.audioMessage && + conversationId === state.conversations.selectedConversationId && + isActive && + !isJustSent && + messages.some(isIncoming) + ) { + drop(new Sound({ soundType: SoundType.Pop }).play()); + } + + dispatch({ + type: 'MESSAGES_ADDED', + payload: { + conversationId, + isActive, + isJustSent, + isNewMessage, + messages, + }, + }); }; } diff --git a/ts/util/Sound.ts b/ts/util/Sound.ts index 020ef2056d35..c09bde5b2a43 100644 --- a/ts/util/Sound.ts +++ b/ts/util/Sound.ts @@ -112,7 +112,7 @@ export class Sound { } if (soundStyle === SoundType.Pop) { - return 'sounds/pop.wav'; + return 'sounds/pop.ogg'; } if (soundStyle === SoundType.TriTone) { @@ -132,7 +132,7 @@ export class Sound { } if (soundStyle === SoundType.Whoosh) { - return 'sounds/whoosh.wav'; + return 'sounds/whoosh.ogg'; } throw missingCaseError(soundStyle);