);
}
return false;
}
playSoundForUnreadMessages() {
const snd = new Audio('/html5client/resources/sounds/notify.mp3');
snd.play();
}
componentDidUpdate(prevProps) {
let { unreadMessageCount, openChats, openChat } = this.props;
unreadMessageCount.forEach((chat, i) => {
// When starting the new chat, if prevProps is undefined or null, it is assigned 0.
if (!prevProps.unreadMessageCount[i]) {
prevProps.unreadMessageCount[i] = 0;
}
// compare openChats(chatID) to chatID of currently opened chat room
if (openChats[i] !== openChat) {
let shouldPlaySound = LocalStorage.getItem('audioNotifChat') || Meteor.settings.public.app.audioChatNotification;
if (shouldPlaySound && chat > prevProps.unreadMessageCount[i]) {
this.playSoundForUnreadMessages();
}
}
});
}
render() {
if (this.props.wasKicked) {
return (