The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/hooks/notification/useNewMessageNotification.ts

24 lines
884 B

import type { AtLeast, ISubscription } from '@rocket.chat/core-typings';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useCustomSound } from '@rocket.chat/ui-contexts';
export const useNewMessageNotification = () => {
const { notificationSounds } = useCustomSound();
const notifyNewMessage = useEffectEvent((sub: AtLeast<ISubscription, 'rid'>) => {
if (!sub || sub.audioNotificationValue === 'none') {
return;
}
// TODO: Fix this - Room Notifications Preferences > sound > desktop is not working.
// plays the user notificationSound preference
// if (sub.audioNotificationValue && sub.audioNotificationValue !== '0') {
// void CustomSounds.play(sub.audioNotificationValue, {
// volume: Number((notificationsSoundVolume / 100).toPrecision(2)),
// });
// }
notificationSounds.playNewMessage();
});
return notifyNewMessage;
};