mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-17 22:10:23 +01:00
feat: closes #11139, move sort settings to user settings page
don't change user settings when user changes sort inside topic/category
This commit is contained in:
@@ -100,10 +100,10 @@
|
||||
"nodebb-plugin-ntfy": "1.0.15",
|
||||
"nodebb-plugin-spam-be-gone": "2.0.6",
|
||||
"nodebb-rewards-essentials": "0.2.2",
|
||||
"nodebb-theme-harmony": "1.0.0-beta.78",
|
||||
"nodebb-theme-harmony": "1.0.0-beta.79",
|
||||
"nodebb-theme-lavender": "7.0.9",
|
||||
"nodebb-theme-peace": "2.0.19",
|
||||
"nodebb-theme-persona": "13.0.50",
|
||||
"nodebb-theme-persona": "13.0.51",
|
||||
"nodebb-widget-essentials": "7.0.6",
|
||||
"nodemailer": "6.9.1",
|
||||
"nprogress": "0.2.0",
|
||||
|
||||
@@ -126,6 +126,8 @@
|
||||
"paginate_description" : "Paginate topics and posts instead of using infinite scroll",
|
||||
"topics_per_page": "Topics per Page",
|
||||
"posts_per_page": "Posts per Page",
|
||||
"category-topic-sort": "Category topic sort",
|
||||
"topic-post-sort": "Topic post sort",
|
||||
"max_items_per_page": "Maximum %1",
|
||||
"acp_language": "Admin Page Language",
|
||||
"notifications": "Notifications",
|
||||
|
||||
@@ -1,36 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('sort', ['components', 'api'], function (components, api) {
|
||||
define('sort', ['components'], function (components) {
|
||||
const module = {};
|
||||
|
||||
module.handleSort = function (field, gotoOnSave) {
|
||||
const threadSort = components.get('thread/sort');
|
||||
threadSort.find('i').removeClass('fa-check');
|
||||
const currentSetting = threadSort.find('a[data-sort="' + config[field] + '"]');
|
||||
const currentSort = utils.params().sort || config[field];
|
||||
const currentSetting = threadSort.find('a[data-sort="' + currentSort + '"]');
|
||||
currentSetting.find('i').addClass('fa-check');
|
||||
|
||||
$('body')
|
||||
.off('click', '[component="thread/sort"] a')
|
||||
.on('click', '[component="thread/sort"] a', function () {
|
||||
function refresh(newSetting, params) {
|
||||
config[field] = newSetting;
|
||||
const qs = decodeURIComponent($.param(params));
|
||||
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
|
||||
}
|
||||
const newSetting = $(this).attr('data-sort');
|
||||
if (app.user.uid) {
|
||||
const payload = { settings: {} };
|
||||
payload.settings[field] = newSetting;
|
||||
api.put(`/users/${app.user.uid}/settings`, payload).then(() => {
|
||||
// Yes, this is normal. If you are logged in, sort is not added to qs since it's saved to user settings
|
||||
refresh(newSetting, utils.params());
|
||||
});
|
||||
} else {
|
||||
const urlParams = utils.params();
|
||||
urlParams.sort = newSetting;
|
||||
refresh(newSetting, urlParams);
|
||||
}
|
||||
const qs = decodeURIComponent($.param(urlParams));
|
||||
ajaxify.go(gotoOnSave + (qs ? '?' + qs : ''));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user