default sounds to off, show correct setting in user settings page

This commit is contained in:
barisusakli
2016-09-05 21:47:13 +03:00
parent 481ecdd642
commit c01a2bfa33
4 changed files with 19 additions and 10 deletions

View File

@@ -39,6 +39,9 @@ settingsController.get = function(req, res, callback) {
},
sounds: function(next) {
meta.sounds.getFiles(next);
},
soundsMapping: function(next) {
meta.sounds.getMapping(userData.uid, next);
}
}, next);
},
@@ -47,10 +50,15 @@ settingsController.get = function(req, res, callback) {
userData.languages = results.languages;
userData.homePageRoutes = results.homePageRoutes;
var soundSettings = ['notificationSound', 'incomingChatSound', 'outgoingChatSound'];
soundSettings.forEach(function(setting) {
var soundSettings = {
'notificationSound': 'notification',
'incomingChatSound': 'chat-incoming',
'outgoingChatSound': 'chat-outgoing'
};
Object.keys(soundSettings).forEach(function(setting) {
userData[setting] = Object.keys(results.sounds).map(function(name) {
return {name: name, selected: name === userData.settings[setting]};
return {name: name, selected: name === results.soundsMapping[soundSettings[setting]]};
});
});