From 055c0d3bf4680e531e71a6e1dc57f156672bf7ec Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 11 Oct 2024 00:28:05 +0200 Subject: [PATCH] Added setting for default messages sort mode --- dev/Settings/User/General.js | 49 ++++++++++++++++++- dev/Stores/User/Folder.js | 3 +- dev/Stores/User/Settings.js | 2 + .../libraries/RainLoop/Actions/Accounts.php | 2 + .../app/libraries/RainLoop/Actions/User.php | 1 + .../v/0.0.0/app/localization/nl/user.json | 4 +- .../templates/Views/User/SettingsGeneral.html | 5 ++ 7 files changed, 61 insertions(+), 5 deletions(-) diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index a05a3227d..f06349c25 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -44,6 +44,51 @@ export class UserSettingsGeneral extends AbstractViewSettings { this.desktopNotifications = NotificationUserStore.enabled; this.isDesktopNotificationAllowed = NotificationUserStore.allowed; + const i18nSort = s => i18n('MESSAGE_LIST/SORT_'+s); + this.sortSupported = FolderUserStore.hasCapability('SORT'); + this.sortOptions = [ + { + value: '', + text: i18nSort('DATE_DESC') + }, + { + value: 'DATE', + text: i18nSort('DATE_ASC') + }, + { + value: 'FROM', + text: i18nSort('FROM_ASC') + }, + { + value: 'REVERSE FROM', + text: i18nSort('FROM_DESC') + }, + { + value: 'REVERSE SIZE', + text: i18nSort('SIZE_DESC') + }, + { + value: 'SIZE', + text: i18nSort('SIZE_ASC') + }, + { + value: 'SUBJECT', + text: i18nSort('SUBJECT_ASC') + }, + { + value: 'REVERSE SUBJECT', + text: i18nSort('SUBJECT_DESC') + }, + { + value: 'REVERSE ARRIVAL', + text: i18nSort('ARRIVAL_DESC') + }, + { + value: 'ARRIVAL', + text: i18nSort('ARRIVAL_ASC') + } + ]; + this.threadsAllowed = AppUserStore.threadsAllowed; // 'THREAD=REFS', 'THREAD=REFERENCES', 'THREAD=ORDEREDSUBJECT' this.threadAlgorithms = ko.observableArray(); @@ -51,9 +96,8 @@ export class UserSettingsGeneral extends AbstractViewSettings { capa.startsWith('THREAD=') && this.threadAlgorithms.push(capa.slice(7)) ); this.threadAlgorithms.sort((a, b) => a.length - b.length); - this.threadAlgorithm = SettingsUserStore.threadAlgorithm; - ['useThreads', 'threadAlgorithm', + ['defaultSort', 'useThreads', 'threadAlgorithm', // These use addSetting() 'layout', 'messageReadDelay', 'messagesPerPage', 'checkMailInterval', 'editorDefaultType', 'editorWysiwyg', 'msgDefaultAction', 'maxBlockquotesLevel', @@ -117,6 +161,7 @@ export class UserSettingsGeneral extends AbstractViewSettings { this.addSetting('CheckMailInterval'); this.addSetting('Layout'); this.addSetting('MaxBlockquotesLevel'); + this.addSetting('defaultSort'); this.addSettings([ 'requestReadReceipt', 'requestDsn', 'requireTLS', 'pgpSign', 'pgpEncrypt', diff --git a/dev/Stores/User/Folder.js b/dev/Stores/User/Folder.js index 37007c768..12983b373 100644 --- a/dev/Stores/User/Folder.js +++ b/dev/Stores/User/Folder.js @@ -7,6 +7,7 @@ import { forEachObjectEntry } from 'Common/Utils'; import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache'; import { Settings, SettingsCapa } from 'Common/Globals'; //import Remote from 'Remote/User/Fetch'; // Circular dependency +import { SettingsUserStore } from 'Stores/User/Settings'; export const @@ -59,7 +60,7 @@ FolderUserStore = new class { */ displaySpecSetting: false, - sortMode: '', + sortMode: SettingsUserStore.defaultSort(), quotaLimit: 0, quotaUsage: 0, diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index 382c74289..211a89288 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -29,6 +29,7 @@ export const SettingsUserStore = new class { showNextMessage: 0, allowDraftAutosave: 1, useThreads: 0, + defaultSort: '', threadAlgorithm: '', replySameFolder: 0, hideUnsubscribed: 0, @@ -103,6 +104,7 @@ export const SettingsUserStore = new class { 'showNextMessage', 'AllowDraftAutosave', 'useThreads', + 'defaultSort', 'threadAlgorithm', 'ReplySameFolder', 'HideUnsubscribed', diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php index 2a4e40bb0..4e78236e9 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php @@ -210,6 +210,7 @@ trait Accounts 'mainEmail' => \RainLoop\Api::Actions()->getMainAccountFromToken()->Email(), 'contactsAllowed' => $this->AddressBookProvider($oAccount)->IsActive(), 'HideUnsubscribed' => false, + 'defaultSort' => '', 'useThreads' => (bool) $oConfig->Get('defaults', 'mail_use_threads', false), 'threadAlgorithm' => '', 'ReplySameFolder' => (bool) $oConfig->Get('defaults', 'mail_reply_same_folder', false), @@ -226,6 +227,7 @@ trait Accounts $aResult['TrashFolder'] = (string) $oSettingsLocal->GetConf('TrashFolder', ''); $aResult['ArchiveFolder'] = (string) $oSettingsLocal->GetConf('ArchiveFolder', ''); $aResult['HideUnsubscribed'] = (bool) $oSettingsLocal->GetConf('HideUnsubscribed', $aResult['HideUnsubscribed']); + $aResult['defaultSort'] = (string) $oSettingsLocal->GetConf('defaultSort', $aResult['defaultSort']); $aResult['useThreads'] = (bool) $oSettingsLocal->GetConf('UseThreads', $aResult['useThreads']); $aResult['threadAlgorithm'] = (string) $oSettingsLocal->GetConf('threadAlgorithm', $aResult['threadAlgorithm']); $aResult['ReplySameFolder'] = (bool) $oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php index 014f403e7..f1a19c172 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php @@ -204,6 +204,7 @@ trait User $this->setSettingsFromParams($oSettings, 'Resizer5Width', 'int'); $this->setSettingsFromParams($oSettings, 'Resizer5Height', 'int'); + $this->setSettingsFromParams($oSettingsLocal, 'defaultSort', 'string'); $this->setSettingsFromParams($oSettingsLocal, 'UseThreads', 'bool'); $this->setSettingsFromParams($oSettingsLocal, 'threadAlgorithm', 'string'); $this->setSettingsFromParams($oSettingsLocal, 'ReplySameFolder', 'bool'); diff --git a/snappymail/v/0.0.0/app/localization/nl/user.json b/snappymail/v/0.0.0/app/localization/nl/user.json index 27db22c00..e94df562b 100644 --- a/snappymail/v/0.0.0/app/localization/nl/user.json +++ b/snappymail/v/0.0.0/app/localization/nl/user.json @@ -130,8 +130,8 @@ "QUOTA_SIZE": "U gebruikt %SIZE% (%PROC%%)<\/strong> van %LIMIT%<\/strong>", "SORT": "Sorteren", "NO_SORT": "Mail server ondersteund sorteren niet", - "SORT_ARRIVAL_ASC": "Arrived ascending", - "SORT_ARRIVAL_DESC": "Arrived descending", + "SORT_ARRIVAL_ASC": "Ontvangen oplopend", + "SORT_ARRIVAL_DESC": "Ontvangen aflopend", "SORT_DATE_ASC": "Datum oplopend", "SORT_DATE_DESC": "Datum aflopend", "SORT_SIZE_ASC": "Grootte oplopend", diff --git a/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html b/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html index 233149db3..4a81406b9 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html @@ -65,6 +65,11 @@ +
+ + + +