From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Sat, 19 Mar 2022 13:25:57 +0000 (+0530) Subject: Add sound on incoming invites (#400) X-Git-Tag: v2.0.0~94 X-Git-Url: https://git.wafflesoft.org/?a=commitdiff_plain;h=36da3d3cba5109f6962de065a0201ff534940a6d;p=cinny.git Add sound on incoming invites (#400) * Add invite sound Signed-off-by: Ajay Bura * Add credits Signed-off-by: Ajay Bura * Change invite sound to google material --- diff --git a/public/sound/invite.ogg b/public/sound/invite.ogg new file mode 100755 index 0000000..4a00af6 Binary files /dev/null and b/public/sound/invite.ogg differ diff --git a/src/client/state/Notifications.js b/src/client/state/Notifications.js index 7bcd950..9633852 100644 --- a/src/client/state/Notifications.js +++ b/src/client/state/Notifications.js @@ -7,6 +7,7 @@ import navigation from './navigation'; import settings from './settings'; import NotificationSound from '../../../public/sound/notification.ogg'; +import InviteSound from '../../../public/sound/invite.ogg'; function isNotifEvent(mEvent) { const eType = mEvent.getType(); @@ -222,21 +223,28 @@ class Notifications extends EventEmitter { silent: settings.isNotificationSounds, }); if (settings.isNotificationSounds) { - noti.onshow = () => this._playNotiSounds(); + noti.onshow = () => this._playNotiSound(); } noti.onclick = () => selectRoom(room.roomId, mEvent.getId()); } else { - this._playNotiSounds(); + this._playNotiSound(); } } - _playNotiSounds() { + _playNotiSound() { if (!this._notiAudio) { this._notiAudio = new Audio(NotificationSound); } this._notiAudio.play(); } + _playInviteSound() { + if (!this._inviteAudio) { + this._inviteAudio = new Audio(InviteSound); + } + this._inviteAudio.play(); + } + _listenEvents() { this.matrixClient.on('Room.timeline', (mEvent, room) => { if (room.isSpaceRoom()) return; @@ -316,6 +324,9 @@ class Notifications extends EventEmitter { if (membership === 'leave' && this.hasNoti(room.roomId)) { this.deleteNoti(room.roomId); } + if (membership === 'invite') { + this._playInviteSound(); + } }); } }