mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-04 21:15:55 +01:00
Fix #5476
This commit is contained in:
@@ -13,20 +13,6 @@ define('admin/general/sounds', ['sounds', 'settings', 'admin/settings'], functio
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var plugins = require('../../plugins');
|
||||
var db = require('../../database');
|
||||
var meta = require('../../meta');
|
||||
|
||||
var soundsController = {};
|
||||
|
||||
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) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
settings = settings || {};
|
||||
|
||||
var types = [
|
||||
'notification',
|
||||
'chat-incoming',
|
||||
'chat-outgoing',
|
||||
];
|
||||
var output = {};
|
||||
|
||||
types.forEach(function (type) {
|
||||
|
||||
@@ -9,8 +9,6 @@ var async = require('async');
|
||||
var file = require('../file');
|
||||
var plugins = require('../plugins');
|
||||
var user = require('../user');
|
||||
var db = require('../database');
|
||||
|
||||
|
||||
var soundsPath = path.join(__dirname, '../../build/public/sounds');
|
||||
var uploadsPath = path.join(__dirname, '../../public/uploads/sounds');
|
||||
@@ -100,7 +98,7 @@ module.exports = function (Meta) {
|
||||
Meta.sounds.getUserSoundMap = function getUserSoundMap(uid, callback) {
|
||||
async.parallel({
|
||||
defaultMapping: function (next) {
|
||||
db.getObject('settings:sounds', next);
|
||||
Meta.configs.getFields(keys, next);
|
||||
},
|
||||
userSettings: function (next) {
|
||||
user.getSettings(uid, next);
|
||||
@@ -112,18 +110,18 @@ module.exports = function (Meta) {
|
||||
|
||||
var userSettings = results.userSettings;
|
||||
userSettings = {
|
||||
notification: userSettings.notificationSound,
|
||||
'chat-incoming': userSettings.incomingChatSound,
|
||||
'chat-outgoing': userSettings.outgoingChatSound,
|
||||
notification: userSettings.notificationSound || userSettings['notification-sound'],
|
||||
'chat-incoming': userSettings.incomingChatSound || userSettings['chat-incoming-sound'],
|
||||
'chat-outgoing': userSettings.outgoingChatSound || userSettings['chat-outgoing-sound'],
|
||||
};
|
||||
var defaultMapping = results.defaultMapping || {};
|
||||
var soundMapping = {};
|
||||
|
||||
keys.forEach(function (key) {
|
||||
if (userSettings[key] || userSettings[key] === '') {
|
||||
soundMapping[key] = userSettings[key] || null;
|
||||
soundMapping[key] = userSettings[key] || '';
|
||||
} else {
|
||||
soundMapping[key] = defaultMapping[key] || null;
|
||||
soundMapping[key] = defaultMapping[key] || '';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<label for="notification">[[admin/general/sounds:notifications]]</label>
|
||||
<div class="row">
|
||||
<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>
|
||||
<!-- BEGIN notification-sound -->
|
||||
<optgroup label="{notification-sound.name}">
|
||||
@@ -33,7 +33,7 @@
|
||||
<label for="chat-incoming">[[admin/general/sounds:incoming-message]]</label>
|
||||
<div class="row">
|
||||
<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>
|
||||
<!-- BEGIN chat-incoming-sound -->
|
||||
<optgroup label="{chat-incoming-sound.name}">
|
||||
@@ -54,7 +54,7 @@
|
||||
<label for="chat-outgoing">[[admin/general/sounds:outgoing-message]]</label>
|
||||
<div class="row">
|
||||
<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>
|
||||
<!-- BEGIN chat-outgoing-sound -->
|
||||
<optgroup label="{chat-outgoing-sound.name}">
|
||||
|
||||
Reference in New Issue
Block a user