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

v1.18.x
barisusakli 9 years ago
parent 481ecdd642
commit c01a2bfa33

@ -102,6 +102,7 @@
"incoming-message-sound": "Incoming message sound",
"outgoing-message-sound": "Outgoing message sound",
"notification-sound": "Notification sound",
"no-sound": "No sound",
"browsing": "Browsing Settings",
"open_links_in_new_tab": "Open outgoing links in new tab",

@ -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]]};
});
});

@ -75,13 +75,13 @@ module.exports = function(Meta) {
var defaultMapping = results.defaultMapping || {};
var soundMapping = {};
soundMapping.notification = (userSettings.notificationSound || userSettings.notificationSound === '') ?
userSettings.notificationSound : defaultMapping.notification || 'notification.mp3';
userSettings.notificationSound : defaultMapping.notification || '';
soundMapping['chat-incoming'] = (userSettings.incomingChatSound || userSettings.incomingChatSound === '') ?
userSettings.incomingChatSound : defaultMapping['chat-incoming'] || 'waterdrop-high.mp3';
userSettings.incomingChatSound : defaultMapping['chat-incoming'] || '';
soundMapping['chat-outgoing'] = (userSettings.outgoingChatSound || userSettings.outgoingChatSound === '') ?
userSettings.outgoingChatSound : defaultMapping['chat-outgoing'] || undefined;
userSettings.outgoingChatSound : defaultMapping['chat-outgoing'] || '';
callback(null, soundMapping);
});

@ -8,7 +8,7 @@
<div class="row">
<div class="form-group col-xs-9">
<select class="form-control" id="notification" name="notification">
<option value=""></option>
<option value="">[[user:no-sound]]</option>
<!-- BEGIN sounds -->
<option value="{sounds.name}">{sounds.name}</option>
<!-- END sounds -->
@ -28,7 +28,7 @@
<div class="row">
<div class="form-group col-xs-9">
<select class="form-control" id="chat-incoming" name="chat-incoming">
<option value=""></option>
<option value="">[[user:no-sound]]</option>
<!-- BEGIN sounds -->
<option value="{sounds.name}">{sounds.name}</option>
<!-- END sounds -->
@ -43,7 +43,7 @@
<div class="row">
<div class="form-group col-xs-9">
<select class="form-control" id="chat-outgoing" name="chat-outgoing">
<option value=""></option>
<option value="">[[user:no-sound]]</option>
<!-- BEGIN sounds -->
<option value="{sounds.name}">{sounds.name}</option>
<!-- END sounds -->
@ -53,7 +53,7 @@
<button type="button" class="form-control btn btn-sm btn-default" data-action="play"><span class="hidden-xs">Play </span><i class="fa fa-play"></i></button>
</div>
</div>
<div class="input-group">
<span class="input-group-btn">
<input data-action="upload" data-title="Upload Sound" data-route="{config.relative_path}/api/admin/upload/sound" type="button" class="btn btn-primary" value="Upload New Sound"></input>

Loading…
Cancel
Save