Skip to content
1 change: 0 additions & 1 deletion apps/meteor/app/custom-sounds/client/index.ts

This file was deleted.

147 changes: 0 additions & 147 deletions apps/meteor/app/custom-sounds/client/lib/CustomSounds.ts

This file was deleted.

10 changes: 0 additions & 10 deletions apps/meteor/app/utils/client/getUserNotificationsSoundVolume.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import type { AtLeast, ISubscription } from '@rocket.chat/core-typings';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useUserPreference } from '@rocket.chat/ui-contexts';

import { CustomSounds } from '../../../app/custom-sounds/client/lib/CustomSounds';
import { useUserSoundPreferences } from '../useUserSoundPreferences';
import { useCustomSound } from '@rocket.chat/ui-contexts';

export const useNewMessageNotification = () => {
const newMessageNotification = useUserPreference<string>('newMessageNotification');
const { notificationsSoundVolume } = useUserSoundPreferences();
const { notificationSounds } = useCustomSound();

const notifyNewMessage = useEffectEvent((sub: AtLeast<ISubscription, 'rid'>) => {
if (!sub || sub.audioNotificationValue === 'none') {
return;
}
if (sub.audioNotificationValue && sub.audioNotificationValue !== '0') {
void CustomSounds.play(sub.audioNotificationValue, {
volume: Number((notificationsSoundVolume / 100).toPrecision(2)),
});
}
// TODO: Fix this - Room Notifications Preferences > sound > desktop is not working.
// plays the user notificationSound preference

if (newMessageNotification && newMessageNotification !== 'none') {
void CustomSounds.play(newMessageNotification, {
volume: Number((notificationsSoundVolume / 100).toPrecision(2)),
});
}
// if (sub.audioNotificationValue && sub.audioNotificationValue !== '0') {
// void CustomSounds.play(sub.audioNotificationValue, {
// volume: Number((notificationsSoundVolume / 100).toPrecision(2)),
// });
// }

notificationSounds.playNewMessage();
});
return notifyNewMessage;
};
22 changes: 0 additions & 22 deletions apps/meteor/client/hooks/notification/useNewRoomNotification.ts

This file was deleted.

10 changes: 5 additions & 5 deletions apps/meteor/client/hooks/notification/useNotifyUser.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { AtLeast, INotificationDesktop, ISubscription } from '@rocket.chat/core-typings';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useRouter, useStream, useUser, useUserPreference } from '@rocket.chat/ui-contexts';
import { useCustomSound, useRouter, useStream, useUser, useUserPreference } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { useEmbeddedLayout } from '../useEmbeddedLayout';
import { useDesktopNotification } from './useDesktopNotification';
import { useNewMessageNotification } from './useNewMessageNotification';
import { useNewRoomNotification } from './useNewRoomNotification';
import { CachedChatSubscription } from '../../../app/models/client';
import { RoomManager } from '../../lib/RoomManager';
import { fireGlobalEvent } from '../../lib/utils/fireGlobalEvent';
Expand All @@ -17,7 +16,7 @@ export const useNotifyUser = () => {
const isLayoutEmbedded = useEmbeddedLayout();
const notifyUserStream = useStream('notify-user');
const muteFocusedConversations = useUserPreference('muteFocusedConversations');
const newRoomNotification = useNewRoomNotification();
const { notificationSounds } = useCustomSound();
const newMessageNotification = useNewMessageNotification();
const showDesktopNotification = useDesktopNotification();

Expand All @@ -27,7 +26,7 @@ export const useNotifyUser = () => {
}

if ((!router.getRouteParameters().name || router.getRouteParameters().name !== sub.name) && !sub.ls && sub.alert === true) {
newRoomNotification();
notificationSounds.playNewRoom();
}
});

Expand Down Expand Up @@ -83,6 +82,7 @@ export const useNotifyUser = () => {
unsubNotification();
unsubSubs();
handle.stop();
notificationSounds.stopNewRoom();
};
}, [isLayoutEmbedded, notifyNewMessageAudioAndDesktop, notifyNewRoom, notifyUserStream, router, user?._id]);
}, [isLayoutEmbedded, notificationSounds, notifyNewMessageAudioAndDesktop, notifyNewRoom, notifyUserStream, router, user?._id]);
};
Original file line number Diff line number Diff line change
@@ -1,54 +1,28 @@
import type { ICustomSound } from '@rocket.chat/core-typings';
import { useSetting, useUserPreference, useUserSubscriptions } from '@rocket.chat/ui-contexts';
import { useCustomSound, useSetting, useUserSubscriptions } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { useUserSoundPreferences } from './useUserSoundPreferences';
import { CustomSounds } from '../../app/custom-sounds/client/lib/CustomSounds';

const query = { t: 'l', ls: { $exists: false }, open: true };
export const useOmnichannelContinuousSoundNotification = <T>(queue: T[]) => {
const userSubscriptions = useUserSubscriptions(query);
const { notificationSounds } = useCustomSound();

const playNewRoomSoundContinuously = useSetting('Livechat_continuous_sound_notification_new_livechat_room');

const newRoomNotification = useUserPreference<string>('newRoomNotification');
const { notificationsSoundVolume } = useUserSoundPreferences();

const continuousCustomSoundId = newRoomNotification && `${newRoomNotification}-continuous`;

const hasUnreadRoom = userSubscriptions.length > 0 || queue.length > 0;

useEffect(() => {
let audio: ICustomSound;
if (playNewRoomSoundContinuously && continuousCustomSoundId) {
audio = { ...CustomSounds.getSound(newRoomNotification), _id: continuousCustomSoundId };
CustomSounds.add(audio);
}

return () => {
if (audio) {
CustomSounds.remove(audio);
}
};
}, [continuousCustomSoundId, newRoomNotification, playNewRoomSoundContinuously]);

useEffect(() => {
if (!continuousCustomSoundId) {
return;
}
if (!playNewRoomSoundContinuously) {
CustomSounds.pause(continuousCustomSoundId);
return;
}

if (!hasUnreadRoom) {
CustomSounds.pause(continuousCustomSoundId);
return;
}

CustomSounds.play(continuousCustomSoundId, {
volume: notificationsSoundVolume / 100,
loop: true,
});
}, [continuousCustomSoundId, playNewRoomSoundContinuously, userSubscriptions, notificationsSoundVolume, hasUnreadRoom]);
notificationSounds.playNewMessageLoop();

return () => {
notificationSounds.stopNewRoom();
};
}, [playNewRoomSoundContinuously, userSubscriptions, hasUnreadRoom, notificationSounds]);
};
1 change: 0 additions & 1 deletion apps/meteor/client/importPackages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '../app/apple/client';
import '../app/authorization/client';
import '../app/autotranslate/client';
import '../app/custom-sounds/client';
import '../app/emoji/client';
import '../app/emoji-emojione/client';
import '../app/emoji-custom/client';
Expand Down
12 changes: 7 additions & 5 deletions apps/meteor/client/providers/CallProvider/CallProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import {
useSetInputMediaDevice,
useSetModal,
useTranslation,
useCustomSound,
} from '@rocket.chat/ui-contexts';
import type { ReactNode } from 'react';
import { useMemo, useRef, useCallback, useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import type { OutgoingByeRequest } from 'sip.js/lib/core';

import { useVoipSounds } from './hooks/useVoipSounds';
import type { CallContextValue } from '../../contexts/CallContext';
import { CallContext, useIsVoipEnterprise } from '../../contexts/CallContext';
import { useDialModal } from '../../hooks/useDialModal';
Expand Down Expand Up @@ -73,7 +73,7 @@ export const CallProvider = ({ children }: CallProviderProps) => {

const { openDialModal } = useDialModal();

const voipSounds = useVoipSounds();
const { voipSounds } = useCustomSound();

const closeRoom = useCallback(
async (
Expand Down Expand Up @@ -336,7 +336,9 @@ export const CallProvider = ({ children }: CallProviderProps) => {
if (!callDetails.callInfo) {
return;
}

voipSounds.stopAll();

if (callDetails.userState !== UserState.UAC) {
return;
}
Expand Down Expand Up @@ -377,15 +379,15 @@ export const CallProvider = ({ children }: CallProviderProps) => {
};

const onRinging = (): void => {
voipSounds.play('outbound-call-ringing');
voipSounds.playDialer();
};

const onIncomingCallRinging = (): void => {
voipSounds.play('telephone');
voipSounds.playRinger();
};

const onCallTerminated = (): void => {
voipSounds.play('call-ended', false);
voipSounds.playCallEnded();
voipSounds.stopAll();
};

Expand Down
Loading
Loading