Hand raised sound

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
ayumi-signal 2024-01-10 21:57:36 -08:00 committed by GitHub
parent 980f162c96
commit c126ca1016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 2 deletions

BIN
sounds/notification_simple-01.ogg Executable file

Binary file not shown.

View file

@ -15,6 +15,7 @@ import * as Errors from '../../types/errors';
import { getPlatform } from '../selectors/user';
import { isConversationTooBigToRing } from '../../conversations/isConversationTooBigToRing';
import { missingCaseError } from '../../util/missingCaseError';
import { drop } from '../../util/drop';
import { calling } from '../../services/calling';
import { truncateAudioLevel } from '../../calling/truncateAudioLevel';
import type { StateType as RootStateType } from '../reducer';
@ -974,8 +975,26 @@ function receiveGroupCallReactions(
function groupCallRaisedHandsChange(
payload: GroupCallRaisedHandsChangeActionPayloadType
): GroupCallRaisedHandsChangeActionType {
return { type: GROUP_CALL_RAISED_HANDS_CHANGE, payload };
): ThunkAction<
void,
RootStateType,
unknown,
GroupCallRaisedHandsChangeActionType
> {
return async (dispatch, getState) => {
const { conversationId, raisedHands } = payload;
const existingCall = getGroupCall(conversationId, getState().calling);
const isFirstHandRaised =
existingCall &&
!existingCall.raisedHands?.length &&
raisedHands.length > 0;
if (isFirstHandRaised) {
drop(callingTones.handRaised());
}
dispatch({ type: GROUP_CALL_RAISED_HANDS_CHANGE, payload });
};
}
function groupCallStateChange(

View file

@ -6,6 +6,7 @@ import { missingCaseError } from './missingCaseError';
export enum SoundType {
CallingHangUp,
CallingHandRaised,
CallingPresenting,
Pop,
Ringtone,
@ -103,6 +104,10 @@ export class Sound {
}
static getSrc(soundStyle: SoundType): string {
if (soundStyle === SoundType.CallingHandRaised) {
return 'sounds/notification_simple-01.ogg';
}
if (soundStyle === SoundType.CallingHangUp) {
return 'sounds/navigation-cancel.ogg';
}

View file

@ -14,6 +14,19 @@ const ringtoneEventQueue = new PQueue({
class CallingTones {
private ringtone?: Sound;
async handRaised() {
const canPlayTone = window.Events.getCallRingtoneNotification();
if (!canPlayTone) {
return;
}
const tone = new Sound({
soundType: SoundType.CallingHandRaised,
});
await tone.play();
}
async playEndCall(): Promise<void> {
const canPlayTone = window.Events.getCallRingtoneNotification();
if (!canPlayTone) {