diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json index ec671f6576..a93e9d77d0 100644 --- a/public/language/en_GB/user.json +++ b/public/language/en_GB/user.json @@ -49,5 +49,7 @@ "paginate_description" : "Paginate topics and posts instead of using infinite scroll.", "topics_per_page": "Topics per Page", - "posts_per_page": "Posts per Page" + "posts_per_page": "Posts per Page", + + "notification_sounds" : "Play a sound when you receive a notification." } diff --git a/public/src/modules/sounds.js b/public/src/modules/sounds.js index 1ddb752def..ada1a164fd 100644 --- a/public/src/modules/sounds.js +++ b/public/src/modules/sounds.js @@ -67,6 +67,9 @@ define(['buzz'], function(buzz) { }; Sounds.play = function(name) { + if (!config.notificationSounds) { + return; + } var ready = function() { if (Sounds.mapping[name] && Sounds.loaded[Sounds.mapping[name]]) { Sounds.loaded[Sounds.mapping[name]].play(); diff --git a/src/controllers/api.js b/src/controllers/api.js index 031acf08f0..6b781e1d4a 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -47,6 +47,7 @@ apiController.getConfig = function(req, res, next) { config.usePagination = settings.usePagination; config.topicsPerPage = settings.topicsPerPage; config.postsPerPage = settings.postsPerPage; + config.notificationSounds = settings.notificationSounds; if (res.locals.isAPI) { res.json(200, config); diff --git a/src/user/settings.js b/src/user/settings.js index 79b5250bd2..bc28622960 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -28,7 +28,7 @@ module.exports = function(User) { settings.usePagination = settings.usePagination ? parseInt(settings.usePagination, 10) === 1 : parseInt(meta.config.usePagination, 10) === 1; settings.topicsPerPage = settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : parseInt(meta.config.topicsPerPage, 10) || 20; settings.postsPerPage = settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : parseInt(meta.config.postsPerPage, 10) || 10; - + settings.notificationSounds = settings.notificationSounds ? parseInt(settings.notificationSounds, 10) === 1 : true; callback(null, settings); }); }); @@ -46,7 +46,8 @@ module.exports = function(User) { showemail: data.showemail, usePagination: data.usePagination, topicsPerPage: data.topicsPerPage, - postsPerPage: data.postsPerPage + postsPerPage: data.postsPerPage, + notificationSounds: data.notificationSounds }, callback); }; }; \ No newline at end of file