diff --git a/src/Notifier.js b/src/Notifier.js
index d5810fe30d..2aad99875c 100644
--- a/src/Notifier.js
+++ b/src/Notifier.js
@@ -120,11 +120,11 @@ const Notifier = {
};
},
- _playAudioNotification: function(ev, room) {
- this.getSoundForRoom(room.roomId).then((sound) => {
- console.log(`Got sound ${sound.name || "default"} for ${room.roomId}`);
- // XXX: How do we ensure this is a sound file and not
- // going to be exploited?
+ _playAudioNotification: async function(ev, room) {
+ const sound = SettingsStore.isFeatureEnabled("feature_notification_sounds") ? await this.getSoundForRoom(room.roomId) : null;
+ console.log(`Got sound ${sound.name || "default"} for ${room.roomId}`);
+ // XXX: How do we ensure this is a sound file and not going to be exploited?
+ try {
const selector = document.querySelector(sound ? `audio[src='${sound.url}']` : "#messageAudio");
let audioElement = selector;
if (!selector) {
@@ -139,9 +139,9 @@ const Notifier = {
document.body.appendChild(audioElement);
}
audioElement.play();
- }).catch((ex) => {
+ } catch (ex) {
console.warn("Caught error when trying to fetch room notification sound:", ex);
- });
+ }
},
start: function() {
diff --git a/src/components/views/dialogs/RoomSettingsDialog.js b/src/components/views/dialogs/RoomSettingsDialog.js
index caed958003..180148aead 100644
--- a/src/components/views/dialogs/RoomSettingsDialog.js
+++ b/src/components/views/dialogs/RoomSettingsDialog.js
@@ -25,6 +25,7 @@ import SecurityRoomSettingsTab from "../settings/tabs/room/SecurityRoomSettingsT
import NotificationSettingsTab from "../settings/tabs/room/NotificationSettingsTab";
import sdk from "../../../index";
import MatrixClientPeg from "../../../MatrixClientPeg";
+import SettingsStore from '../../../settings/SettingsStore';
export default class RoomSettingsDialog extends React.Component {
static propTypes = {
@@ -50,11 +51,15 @@ export default class RoomSettingsDialog extends React.Component {
"mx_RoomSettingsDialog_rolesIcon",
{this.state.currentSound}
+ {_t("Custom Notification Sounds")}: {this.state.currentSound}