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/useOmnichannelContinuousSou...

28 lines
869 B

import { useCustomSound, useSetting, useUserSubscriptions } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';
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 hasUnreadRoom = userSubscriptions.length > 0 || queue.length > 0;
useEffect(() => {
if (!playNewRoomSoundContinuously) {
return;
}
if (!hasUnreadRoom) {
return;
}
notificationSounds.playNewRoomLoop();
return () => {
notificationSounds.stopNewRoom();
};
}, [playNewRoomSoundContinuously, userSubscriptions, hasUnreadRoom, notificationSounds]);
};