dont reload settings page on every save

only show an alert if reload is required
renamed settings.language to settings.userLang to match the config
v1.18.x
Barış Soner Uşaklı 10 years ago
parent 73a0908228
commit 8b21f1c8ab

@ -65,6 +65,7 @@
"digest_monthly": "Monthly",
"send_chat_notifications": "Send an email if a new chat message arrives and I am not online",
"send_post_notifications": "Send an email when replies are made to topics I am subscribed to",
"settings-require-reload": "Some setting changes require a reload. Click here to reload the page.",
"has_no_follower": "This user doesn't have any followers :(",
"follows_no_one": "This user isn't following anyone :(",

@ -36,16 +36,26 @@ define('forum/account/settings', ['forum/account/header'], function(header) {
}
app.alertSuccess('[[success:settings-saved]]');
var requireReload = false;
for (var key in newSettings) {
if (newSettings.hasOwnProperty(key)) {
config[key] = newSettings[key];
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
requireReload = true;
}
config[key] = newSettings[key];
}
}
app.exposeConfigToTemplates();
if (parseInt(app.user.uid, 10) === parseInt(ajaxify.variables.get('theirid'), 10)) {
ajaxify.refresh();
if (requireReload && parseInt(app.user.uid, 10) === parseInt(ajaxify.variables.get('theirid'), 10)) {
app.alert({
id: 'setting-change',
message: '[[user:settings-require-reload]]',
type: 'warning',
timeout: 5000,
clickfn: function() {
ajaxify.refresh();
}
});
}
});

@ -80,7 +80,7 @@ apiController.getConfig = function(req, res, next) {
config.topicsPerPage = settings.topicsPerPage;
config.postsPerPage = settings.postsPerPage;
config.notificationSounds = settings.notificationSounds;
config.userLang = settings.language || config.defaultLang;
config.userLang = settings.userLang || config.defaultLang;
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
config.topicPostSort = settings.topicPostSort || config.topicPostSort;
config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;

@ -41,7 +41,7 @@ var fs = require('fs'),
return callback(err);
}
async.map([results.html, results.plaintext, params.subject], function(raw, next) {
translator.translate(raw, results.settings.language || meta.config.defaultLang || 'en_GB', function(translated) {
translator.translate(raw, results.settings.userLang || meta.config.defaultLang || 'en_GB', function(translated) {
next(undefined, translated);
});
}, function(err, translated) {

@ -303,7 +303,7 @@ middleware.renderHeader = function(req, res, callback) {
if (err) {
return next(err);
}
meta.title.build(req.url.slice(1), settings.language, res.locals, next);
meta.title.build(req.url.slice(1), settings.userLang, res.locals, next);
});
} else {
meta.title.build(req.url.slice(1), meta.config.defaultLang, res.locals, next);

@ -40,7 +40,7 @@ SocketMeta.buildTitle = function(socket, text, callback) {
if (err) {
return callback(err);
}
meta.title.build(text, settings.language, {}, callback);
meta.title.build(text, settings.userLang, {}, callback);
});
} else {
meta.title.build(text, meta.config.defaultLang, {}, callback);

@ -63,7 +63,7 @@ module.exports = function(User) {
settings.topicsPerPage = Math.min(settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : parseInt(meta.config.topicsPerPage, 10) || 20, 20);
settings.postsPerPage = Math.min(settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : parseInt(meta.config.postsPerPage, 10) || 10, 20);
settings.notificationSounds = parseInt(settings.notificationSounds, 10) === 1;
settings.language = settings.language || meta.config.defaultLang || 'en_GB';
settings.userLang = settings.userLang || meta.config.defaultLang || 'en_GB';
settings.topicPostSort = settings.topicPostSort || meta.config.topicPostSort || 'oldest_to_newest';
settings.categoryTopicSort = settings.categoryTopicSort || meta.config.categoryTopicSort || 'newest_to_oldest';
settings.followTopicsOnCreate = (settings.followTopicsOnCreate === null || settings.followTopicsOnCreate === undefined) ? true : parseInt(settings.followTopicsOnCreate, 10) === 1;
@ -82,7 +82,7 @@ module.exports = function(User) {
return callback(new Error('[[error:invalid-pagination-value]]'));
}
data.language = data.language || meta.config.defaultLang;
data.userLang = data.userLang || meta.config.defaultLang;
plugins.fireHook('action:user.saveSettings', {uid: uid, settings: data});
@ -97,7 +97,7 @@ module.exports = function(User) {
topicsPerPage: Math.min(data.topicsPerPage, 20),
postsPerPage: Math.min(data.postsPerPage, 20),
notificationSounds: data.notificationSounds,
language: data.language || meta.config.defaultLang,
userLang: data.userLang || meta.config.defaultLang,
followTopicsOnCreate: data.followTopicsOnCreate,
followTopicsOnReply: data.followTopicsOnReply,
sendChatNotifications: data.sendChatNotifications,

Loading…
Cancel
Save