Merge pull request #5477 from NodeBB/sounds-fix-5476

Fix sounds issue
v1.18.x
Julian Lam 8 years ago committed by GitHub
commit 0213ca4bb1

@ -13,20 +13,6 @@ define('admin/general/sounds', ['sounds', 'settings', 'admin/settings'], functio
Sounds.playSound(soundName); Sounds.playSound(soundName);
}); });
// Load Form Values
Settings.load('sounds', $('.sounds form'));
// Saving of Form Values
var saveEl = $('#save');
saveEl.on('click', function () {
Settings.save('sounds', $('.sounds form'), function () {
socket.emit('admin.fireEvent', {
name: 'event:sounds.reloadMapping',
});
app.alertSuccess('[[admin/general/sounds:saved]]');
});
});
AdminSettings.prepare(); AdminSettings.prepare();
}; };

@ -1,23 +1,23 @@
'use strict'; 'use strict';
var plugins = require('../../plugins'); var plugins = require('../../plugins');
var db = require('../../database'); var meta = require('../../meta');
var soundsController = {}; var soundsController = {};
soundsController.get = function (req, res, next) { soundsController.get = function (req, res, next) {
db.getObject('settings:sounds', function (err, settings) { var types = [
'notification',
'chat-incoming',
'chat-outgoing',
];
meta.configs.getFields(types, function (err, settings) {
if (err) { if (err) {
return next(err); return next(err);
} }
settings = settings || {}; settings = settings || {};
var types = [
'notification',
'chat-incoming',
'chat-outgoing',
];
var output = {}; var output = {};
types.forEach(function (type) { types.forEach(function (type) {

@ -9,8 +9,6 @@ var async = require('async');
var file = require('../file'); var file = require('../file');
var plugins = require('../plugins'); var plugins = require('../plugins');
var user = require('../user'); var user = require('../user');
var db = require('../database');
var soundsPath = path.join(__dirname, '../../build/public/sounds'); var soundsPath = path.join(__dirname, '../../build/public/sounds');
var uploadsPath = path.join(__dirname, '../../public/uploads/sounds'); var uploadsPath = path.join(__dirname, '../../public/uploads/sounds');
@ -100,7 +98,7 @@ module.exports = function (Meta) {
Meta.sounds.getUserSoundMap = function getUserSoundMap(uid, callback) { Meta.sounds.getUserSoundMap = function getUserSoundMap(uid, callback) {
async.parallel({ async.parallel({
defaultMapping: function (next) { defaultMapping: function (next) {
db.getObject('settings:sounds', next); Meta.configs.getFields(keys, next);
}, },
userSettings: function (next) { userSettings: function (next) {
user.getSettings(uid, next); user.getSettings(uid, next);
@ -112,18 +110,18 @@ module.exports = function (Meta) {
var userSettings = results.userSettings; var userSettings = results.userSettings;
userSettings = { userSettings = {
notification: userSettings.notificationSound, notification: userSettings.notificationSound || userSettings['notification-sound'],
'chat-incoming': userSettings.incomingChatSound, 'chat-incoming': userSettings.incomingChatSound || userSettings['chat-incoming-sound'],
'chat-outgoing': userSettings.outgoingChatSound, 'chat-outgoing': userSettings.outgoingChatSound || userSettings['chat-outgoing-sound'],
}; };
var defaultMapping = results.defaultMapping || {}; var defaultMapping = results.defaultMapping || {};
var soundMapping = {}; var soundMapping = {};
keys.forEach(function (key) { keys.forEach(function (key) {
if (userSettings[key] || userSettings[key] === '') { if (userSettings[key] || userSettings[key] === '') {
soundMapping[key] = userSettings[key] || null; soundMapping[key] = userSettings[key] || '';
} else { } else {
soundMapping[key] = defaultMapping[key] || null; soundMapping[key] = defaultMapping[key] || '';
} }
}); });

@ -7,7 +7,7 @@
<label for="notification">[[admin/general/sounds:notifications]]</label> <label for="notification">[[admin/general/sounds:notifications]]</label>
<div class="row"> <div class="row">
<div class="form-group col-xs-9"> <div class="form-group col-xs-9">
<select class="form-control" id="notification" name="notification"> <select class="form-control" id="notification" data-field="notification">
<option value="">[[user:no-sound]]</option> <option value="">[[user:no-sound]]</option>
<!-- BEGIN notification-sound --> <!-- BEGIN notification-sound -->
<optgroup label="{notification-sound.name}"> <optgroup label="{notification-sound.name}">
@ -33,7 +33,7 @@
<label for="chat-incoming">[[admin/general/sounds:incoming-message]]</label> <label for="chat-incoming">[[admin/general/sounds:incoming-message]]</label>
<div class="row"> <div class="row">
<div class="form-group col-xs-9"> <div class="form-group col-xs-9">
<select class="form-control" id="chat-incoming" name="chat-incoming"> <select class="form-control" id="chat-incoming" data-field="chat-incoming">
<option value="">[[user:no-sound]]</option> <option value="">[[user:no-sound]]</option>
<!-- BEGIN chat-incoming-sound --> <!-- BEGIN chat-incoming-sound -->
<optgroup label="{chat-incoming-sound.name}"> <optgroup label="{chat-incoming-sound.name}">
@ -54,7 +54,7 @@
<label for="chat-outgoing">[[admin/general/sounds:outgoing-message]]</label> <label for="chat-outgoing">[[admin/general/sounds:outgoing-message]]</label>
<div class="row"> <div class="row">
<div class="form-group col-xs-9"> <div class="form-group col-xs-9">
<select class="form-control" id="chat-outgoing" name="chat-outgoing"> <select class="form-control" id="chat-outgoing" data-field="chat-outgoing">
<option value="">[[user:no-sound]]</option> <option value="">[[user:no-sound]]</option>
<!-- BEGIN chat-outgoing-sound --> <!-- BEGIN chat-outgoing-sound -->
<optgroup label="{chat-outgoing-sound.name}"> <optgroup label="{chat-outgoing-sound.name}">

Loading…
Cancel
Save