mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closes #2166
This commit is contained in:
@@ -121,5 +121,6 @@
|
|||||||
"allowed-file-types": "Allowed file types are %1",
|
"allowed-file-types": "Allowed file types are %1",
|
||||||
|
|
||||||
"unsaved-changes": "You have unsaved changes. Are you sure you wish to navigate away?",
|
"unsaved-changes": "You have unsaved changes. Are you sure you wish to navigate away?",
|
||||||
"reconnecting-message": "Looks like your connection to %1 was lost, please wait while we try to reconnect."
|
"reconnecting-message": "Looks like your connection to %1 was lost, please wait while we try to reconnect.",
|
||||||
|
"play": "Play"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,10 @@
|
|||||||
"posts_per_page": "Posts per Page",
|
"posts_per_page": "Posts per Page",
|
||||||
|
|
||||||
"notification_sounds" : "Play a sound when you receive a notification",
|
"notification_sounds" : "Play a sound when you receive a notification",
|
||||||
|
"notifications_and_sounds": "Notifications & Sounds",
|
||||||
|
"incoming-message-sound": "Incoming message sound",
|
||||||
|
"outgoing-message-sound": "Outgoing message sound",
|
||||||
|
"notification-sound": "Notification sound",
|
||||||
|
|
||||||
"browsing": "Browsing Settings",
|
"browsing": "Browsing Settings",
|
||||||
"open_links_in_new_tab": "Open outgoing links in new tab",
|
"open_links_in_new_tab": "Open outgoing links in new tab",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*global define, socket, app, ajaxify, config*/
|
/*global define, socket, app, ajaxify, config*/
|
||||||
|
|
||||||
define('forum/account/settings', ['forum/account/header', 'components'], function(header, components) {
|
define('forum/account/settings', ['forum/account/header', 'components', 'sounds'], function(header, components, sounds) {
|
||||||
var AccountSettings = {};
|
var AccountSettings = {};
|
||||||
|
|
||||||
AccountSettings.init = function() {
|
AccountSettings.init = function() {
|
||||||
@@ -33,6 +33,13 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
|
|||||||
|
|
||||||
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
|
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
|
||||||
|
|
||||||
|
$('.account').find('button[data-action="play"]').on('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var fileName = $(this).parent().parent().find('select').val();
|
||||||
|
sounds.playFile(fileName);
|
||||||
|
});
|
||||||
|
|
||||||
toggleCustomRoute();
|
toggleCustomRoute();
|
||||||
|
|
||||||
components.get('user/sessions').find('.timeago').timeago();
|
components.get('user/sessions').find('.timeago').timeago();
|
||||||
@@ -77,9 +84,13 @@ define('forum/account/settings', ['forum/account/header', 'components'], functio
|
|||||||
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
|
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
|
||||||
requireReload = true;
|
requireReload = true;
|
||||||
}
|
}
|
||||||
|
if (config.hasOwnProperty(key)) {
|
||||||
config[key] = newSettings[key];
|
config[key] = newSettings[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sounds.reloadMapping();
|
||||||
|
|
||||||
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
||||||
app.alert({
|
app.alert({
|
||||||
|
|||||||
@@ -9,13 +9,17 @@ define('sounds', ['buzz'], function(buzz) {
|
|||||||
var files;
|
var files;
|
||||||
|
|
||||||
socket.on('event:sounds.reloadMapping', function() {
|
socket.on('event:sounds.reloadMapping', function() {
|
||||||
|
Sounds.reloadMapping();
|
||||||
|
});
|
||||||
|
|
||||||
|
Sounds.reloadMapping = function() {
|
||||||
socket.emit('modules.sounds.getMapping', function(err, mapping) {
|
socket.emit('modules.sounds.getMapping', function(err, mapping) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError('[sounds] Could not load sound mapping!');
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
eventSoundMapping = mapping;
|
eventSoundMapping = mapping;
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
function loadData(callback) {
|
function loadData(callback) {
|
||||||
socket.emit('modules.sounds.getData', function(err, data) {
|
socket.emit('modules.sounds.getData', function(err, data) {
|
||||||
@@ -55,10 +59,6 @@ define('sounds', ['buzz'], function(buzz) {
|
|||||||
Sounds.playFile(eventSoundMapping[name]);
|
Sounds.playFile(eventSoundMapping[name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.notificationSounds) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!eventSoundMapping) {
|
if (!eventSoundMapping) {
|
||||||
return loadData(play);
|
return loadData(play);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
var async = require('async');
|
var async = require('async');
|
||||||
|
|
||||||
var user = require('../../user');
|
var user = require('../../user');
|
||||||
var groups = require('../../groups');
|
|
||||||
var languages = require('../../languages');
|
var languages = require('../../languages');
|
||||||
var meta = require('../../meta');
|
var meta = require('../../meta');
|
||||||
var plugins = require('../../plugins');
|
var plugins = require('../../plugins');
|
||||||
@@ -37,6 +36,9 @@ settingsController.get = function(req, res, callback) {
|
|||||||
},
|
},
|
||||||
homePageRoutes: function(next) {
|
homePageRoutes: function(next) {
|
||||||
getHomePageRoutes(next);
|
getHomePageRoutes(next);
|
||||||
|
},
|
||||||
|
sounds: function(next) {
|
||||||
|
meta.sounds.getFiles(next);
|
||||||
}
|
}
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
@@ -44,6 +46,14 @@ settingsController.get = function(req, res, callback) {
|
|||||||
userData.settings = results.settings;
|
userData.settings = results.settings;
|
||||||
userData.languages = results.languages;
|
userData.languages = results.languages;
|
||||||
userData.homePageRoutes = results.homePageRoutes;
|
userData.homePageRoutes = results.homePageRoutes;
|
||||||
|
|
||||||
|
var soundSettings = ['notificationSound', 'incomingChatSound', 'outgoingChatSound'];
|
||||||
|
soundSettings.forEach(function(setting) {
|
||||||
|
userData[setting] = Object.keys(results.sounds).map(function(name) {
|
||||||
|
return {name: name, selected: name === userData.settings[setting]};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
plugins.fireHook('filter:user.customSettings', {settings: results.settings, customSettings: [], uid: req.uid}, next);
|
plugins.fireHook('filter:user.customSettings', {settings: results.settings, customSettings: [], uid: req.uid}, next);
|
||||||
},
|
},
|
||||||
function(data, next) {
|
function(data, next) {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ var categories = require('../categories');
|
|||||||
var privileges = require('../privileges');
|
var privileges = require('../privileges');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
var widgets = require('../widgets');
|
var widgets = require('../widgets');
|
||||||
var helpers = require('../controllers/helpers');
|
|
||||||
var accountHelpers = require('../controllers/accounts/helpers');
|
var accountHelpers = require('../controllers/accounts/helpers');
|
||||||
|
|
||||||
var apiController = {};
|
var apiController = {};
|
||||||
@@ -68,14 +67,12 @@ apiController.getConfig = function(req, res, next) {
|
|||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
return next(null, config);
|
return next(null, config);
|
||||||
}
|
}
|
||||||
user.getSettings(req.uid, function(err, settings) {
|
user.getSettings(req.uid, next);
|
||||||
if (err) {
|
},
|
||||||
return next(err);
|
function (settings, next) {
|
||||||
}
|
|
||||||
config.usePagination = settings.usePagination;
|
config.usePagination = settings.usePagination;
|
||||||
config.topicsPerPage = settings.topicsPerPage;
|
config.topicsPerPage = settings.topicsPerPage;
|
||||||
config.postsPerPage = settings.postsPerPage;
|
config.postsPerPage = settings.postsPerPage;
|
||||||
config.notificationSounds = settings.notificationSounds;
|
|
||||||
config.userLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.userLang || config.defaultLang;
|
config.userLang = (req.query.lang ? validator.escape(String(req.query.lang)) : null) || settings.userLang || config.defaultLang;
|
||||||
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
|
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
|
||||||
config.topicPostSort = settings.topicPostSort || config.topicPostSort;
|
config.topicPostSort = settings.topicPostSort || config.topicPostSort;
|
||||||
@@ -83,10 +80,6 @@ apiController.getConfig = function(req, res, next) {
|
|||||||
config.topicSearchEnabled = settings.topicSearchEnabled || false;
|
config.topicSearchEnabled = settings.topicSearchEnabled || false;
|
||||||
config.delayImageLoading = settings.delayImageLoading !== undefined ? settings.delayImageLoading : true;
|
config.delayImageLoading = settings.delayImageLoading !== undefined ? settings.delayImageLoading : true;
|
||||||
config.bootswatchSkin = settings.bootswatchSkin || config.bootswatchSkin;
|
config.bootswatchSkin = settings.bootswatchSkin || config.bootswatchSkin;
|
||||||
next(null, config);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function (config, next) {
|
|
||||||
plugins.fireHook('filter:config.get', config, next);
|
plugins.fireHook('filter:config.get', config, next);
|
||||||
}
|
}
|
||||||
], function(err, config) {
|
], function(err, config) {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path'),
|
var path = require('path');
|
||||||
fs = require('fs'),
|
var fs = require('fs');
|
||||||
nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
rimraf = require('rimraf'),
|
var rimraf = require('rimraf');
|
||||||
mkdirp = require('mkdirp'),
|
var mkdirp = require('mkdirp');
|
||||||
async = require('async'),
|
var async = require('async');
|
||||||
|
|
||||||
plugins = require('../plugins'),
|
var user = require('../user');
|
||||||
db = require('../database');
|
var plugins = require('../plugins');
|
||||||
|
var db = require('../database');
|
||||||
|
|
||||||
module.exports = function(Meta) {
|
module.exports = function(Meta) {
|
||||||
|
|
||||||
@@ -58,20 +59,31 @@ module.exports = function(Meta) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Meta.sounds.getMapping = function(callback) {
|
Meta.sounds.getMapping = function(uid, callback) {
|
||||||
db.getObject('settings:sounds', function(err, sounds) {
|
async.parallel({
|
||||||
if (err || !sounds) {
|
defaultMapping: function(next) {
|
||||||
// Send default sounds
|
db.getObject('settings:sounds', next);
|
||||||
var defaults = {
|
},
|
||||||
'notification': 'notification.mp3',
|
userSettings: function(next) {
|
||||||
'chat-incoming': 'waterdrop-high.mp3',
|
user.getSettings(uid, next);
|
||||||
'chat-outgoing': undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
return callback(null, defaults);
|
|
||||||
}
|
}
|
||||||
|
}, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
var userSettings = results.userSettings;
|
||||||
|
var defaultMapping = results.defaultMapping || {};
|
||||||
|
var soundMapping = {};
|
||||||
|
soundMapping.notification = (userSettings.notificationSound || userSettings.notificationSound === '') ?
|
||||||
|
userSettings.notificationSound : defaultMapping.notification || 'notification.mp3';
|
||||||
|
|
||||||
callback(null, sounds);
|
soundMapping['chat-incoming'] = (userSettings.incomingChatSound || userSettings.incomingChatSound === '') ?
|
||||||
|
userSettings.incomingChatSound : defaultMapping['chat-incoming'] || 'waterdrop-high.mp3';
|
||||||
|
|
||||||
|
soundMapping['chat-outgoing'] = (userSettings.outgoingChatSound || userSettings.outgoingChatSound === '') ?
|
||||||
|
userSettings.outgoingChatSound : defaultMapping['chat-outgoing'] || undefined;
|
||||||
|
|
||||||
|
callback(null, soundMapping);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -313,12 +313,12 @@ SocketModules.sounds.getSounds = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.sounds.getMapping = function(socket, data, callback) {
|
SocketModules.sounds.getMapping = function(socket, data, callback) {
|
||||||
meta.sounds.getMapping(callback);
|
meta.sounds.getMapping(socket.uid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketModules.sounds.getData = function(socket, data, callback) {
|
SocketModules.sounds.getData = function(socket, data, callback) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
mapping: async.apply(meta.sounds.getMapping),
|
mapping: async.apply(meta.sounds.getMapping, socket.uid),
|
||||||
files: async.apply(meta.sounds.getFiles)
|
files: async.apply(meta.sounds.getFiles)
|
||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ module.exports = function(User) {
|
|||||||
settings.usePagination = parseInt(getSetting(settings, 'usePagination', 0), 10) === 1;
|
settings.usePagination = parseInt(getSetting(settings, 'usePagination', 0), 10) === 1;
|
||||||
settings.topicsPerPage = Math.min(settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : defaultTopicsPerPage, defaultTopicsPerPage);
|
settings.topicsPerPage = Math.min(settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : defaultTopicsPerPage, defaultTopicsPerPage);
|
||||||
settings.postsPerPage = Math.min(settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : defaultPostsPerPage, defaultPostsPerPage);
|
settings.postsPerPage = Math.min(settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : defaultPostsPerPage, defaultPostsPerPage);
|
||||||
settings.notificationSounds = parseInt(getSetting(settings, 'notificationSounds', 0), 10) === 1;
|
|
||||||
settings.userLang = settings.userLang || meta.config.defaultLang || 'en_GB';
|
settings.userLang = settings.userLang || meta.config.defaultLang || 'en_GB';
|
||||||
settings.topicPostSort = getSetting(settings, 'topicPostSort', 'oldest_to_newest');
|
settings.topicPostSort = getSetting(settings, 'topicPostSort', 'oldest_to_newest');
|
||||||
settings.categoryTopicSort = getSetting(settings, 'categoryTopicSort', 'newest_to_oldest');
|
settings.categoryTopicSort = getSetting(settings, 'categoryTopicSort', 'newest_to_oldest');
|
||||||
@@ -113,7 +112,6 @@ module.exports = function(User) {
|
|||||||
usePagination: data.usePagination,
|
usePagination: data.usePagination,
|
||||||
topicsPerPage: Math.min(data.topicsPerPage, parseInt(meta.config.topicsPerPage, 10) || 20),
|
topicsPerPage: Math.min(data.topicsPerPage, parseInt(meta.config.topicsPerPage, 10) || 20),
|
||||||
postsPerPage: Math.min(data.postsPerPage, parseInt(meta.config.postsPerPage, 10) || 20),
|
postsPerPage: Math.min(data.postsPerPage, parseInt(meta.config.postsPerPage, 10) || 20),
|
||||||
notificationSounds: data.notificationSounds,
|
|
||||||
userLang: data.userLang || meta.config.defaultLang,
|
userLang: data.userLang || meta.config.defaultLang,
|
||||||
followTopicsOnCreate: data.followTopicsOnCreate,
|
followTopicsOnCreate: data.followTopicsOnCreate,
|
||||||
followTopicsOnReply: data.followTopicsOnReply,
|
followTopicsOnReply: data.followTopicsOnReply,
|
||||||
@@ -123,7 +121,10 @@ module.exports = function(User) {
|
|||||||
topicSearchEnabled: data.topicSearchEnabled,
|
topicSearchEnabled: data.topicSearchEnabled,
|
||||||
delayImageLoading: data.delayImageLoading,
|
delayImageLoading: data.delayImageLoading,
|
||||||
homePageRoute : ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''),
|
homePageRoute : ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''),
|
||||||
scrollToMyPost: data.scrollToMyPost
|
scrollToMyPost: data.scrollToMyPost,
|
||||||
|
notificationSound: data.notificationSound,
|
||||||
|
incomingChatSound: data.incomingChatSound,
|
||||||
|
outgoingChatSound: data.outgoingChatSound
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data.bootswatchSkin) {
|
if (data.bootswatchSkin) {
|
||||||
|
|||||||
@@ -261,13 +261,6 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="checkbox">
|
|
||||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
|
||||||
<input class="mdl-switch__input" type="checkbox" data-field="notificationSounds" />
|
|
||||||
<span class="mdl-switch__label">Play a sound when you receive a notification</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user