From 77ddfc642e992b19be213590746f39db73402ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 20 Mar 2023 20:51:03 -0400 Subject: [PATCH] feat: closes #11139, move sort settings to user settings page don't change user settings when user changes sort inside topic/category --- install/package.json | 4 ++-- public/language/en-GB/user.json | 2 ++ public/src/modules/sort.js | 26 +++++++------------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/install/package.json b/install/package.json index 2f6d01d12c..bee02fadce 100644 --- a/install/package.json +++ b/install/package.json @@ -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", diff --git a/public/language/en-GB/user.json b/public/language/en-GB/user.json index 0fafbcf49b..31df96fb8c 100644 --- a/public/language/en-GB/user.json +++ b/public/language/en-GB/user.json @@ -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", diff --git a/public/src/modules/sort.js b/public/src/modules/sort.js index e9307e863e..c7e5e8900a 100644 --- a/public/src/modules/sort.js +++ b/public/src/modules/sort.js @@ -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 urlParams = utils.params(); + urlParams.sort = newSetting; + const qs = decodeURIComponent($.param(urlParams)); + ajaxify.go(gotoOnSave + (qs ? '?' + qs : '')); }); };