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

20 lines
643 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;
}
if (sub?.audioNotificationValue) {
return notificationSounds.playNewMessageCustom(sub.audioNotificationValue);
}
notificationSounds.playNewMessage();
});
return notifyNewMessage;
};