Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 055c0d3

Browse files
author
the-djmaze
committed
Added setting for default messages sort mode
1 parent 16106a2 commit 055c0d3

File tree

7 files changed

+61
-5
lines changed

7 files changed

+61
-5
lines changed

dev/Settings/User/General.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,60 @@ export class UserSettingsGeneral extends AbstractViewSettings {
4444
this.desktopNotifications = NotificationUserStore.enabled;
4545
this.isDesktopNotificationAllowed = NotificationUserStore.allowed;
4646

47+
const i18nSort = s => i18n('MESSAGE_LIST/SORT_'+s);
48+
this.sortSupported = FolderUserStore.hasCapability('SORT');
49+
this.sortOptions = [
50+
{
51+
value: '',
52+
text: i18nSort('DATE_DESC')
53+
},
54+
{
55+
value: 'DATE',
56+
text: i18nSort('DATE_ASC')
57+
},
58+
{
59+
value: 'FROM',
60+
text: i18nSort('FROM_ASC')
61+
},
62+
{
63+
value: 'REVERSE FROM',
64+
text: i18nSort('FROM_DESC')
65+
},
66+
{
67+
value: 'REVERSE SIZE',
68+
text: i18nSort('SIZE_DESC')
69+
},
70+
{
71+
value: 'SIZE',
72+
text: i18nSort('SIZE_ASC')
73+
},
74+
{
75+
value: 'SUBJECT',
76+
text: i18nSort('SUBJECT_ASC')
77+
},
78+
{
79+
value: 'REVERSE SUBJECT',
80+
text: i18nSort('SUBJECT_DESC')
81+
},
82+
{
83+
value: 'REVERSE ARRIVAL',
84+
text: i18nSort('ARRIVAL_DESC')
85+
},
86+
{
87+
value: 'ARRIVAL',
88+
text: i18nSort('ARRIVAL_ASC')
89+
}
90+
];
91+
4792
this.threadsAllowed = AppUserStore.threadsAllowed;
4893
// 'THREAD=REFS', 'THREAD=REFERENCES', 'THREAD=ORDEREDSUBJECT'
4994
this.threadAlgorithms = ko.observableArray();
5095
FolderUserStore.capabilities.forEach(capa =>
5196
capa.startsWith('THREAD=') && this.threadAlgorithms.push(capa.slice(7))
5297
);
5398
this.threadAlgorithms.sort((a, b) => a.length - b.length);
54-
this.threadAlgorithm = SettingsUserStore.threadAlgorithm;
5599

56-
['useThreads', 'threadAlgorithm',
100+
['defaultSort', 'useThreads', 'threadAlgorithm',
57101
// These use addSetting()
58102
'layout', 'messageReadDelay', 'messagesPerPage', 'checkMailInterval',
59103
'editorDefaultType', 'editorWysiwyg', 'msgDefaultAction', 'maxBlockquotesLevel',
@@ -117,6 +161,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
117161
this.addSetting('CheckMailInterval');
118162
this.addSetting('Layout');
119163
this.addSetting('MaxBlockquotesLevel');
164+
this.addSetting('defaultSort');
120165

121166
this.addSettings([
122167
'requestReadReceipt', 'requestDsn', 'requireTLS', 'pgpSign', 'pgpEncrypt',

dev/Stores/User/Folder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { forEachObjectEntry } from 'Common/Utils';
77
import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache';
88
import { Settings, SettingsCapa } from 'Common/Globals';
99
//import Remote from 'Remote/User/Fetch'; // Circular dependency
10+
import { SettingsUserStore } from 'Stores/User/Settings';
1011

1112
export const
1213

@@ -59,7 +60,7 @@ FolderUserStore = new class {
5960
*/
6061
displaySpecSetting: false,
6162

62-
sortMode: '',
63+
sortMode: SettingsUserStore.defaultSort(),
6364

6465
quotaLimit: 0,
6566
quotaUsage: 0,

dev/Stores/User/Settings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const SettingsUserStore = new class {
2929
showNextMessage: 0,
3030
allowDraftAutosave: 1,
3131
useThreads: 0,
32+
defaultSort: '',
3233
threadAlgorithm: '',
3334
replySameFolder: 0,
3435
hideUnsubscribed: 0,
@@ -103,6 +104,7 @@ export const SettingsUserStore = new class {
103104
'showNextMessage',
104105
'AllowDraftAutosave',
105106
'useThreads',
107+
'defaultSort',
106108
'threadAlgorithm',
107109
'ReplySameFolder',
108110
'HideUnsubscribed',

snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public function getAccountData(Account $oAccount): array
210210
'mainEmail' => \RainLoop\Api::Actions()->getMainAccountFromToken()->Email(),
211211
'contactsAllowed' => $this->AddressBookProvider($oAccount)->IsActive(),
212212
'HideUnsubscribed' => false,
213+
'defaultSort' => '',
213214
'useThreads' => (bool) $oConfig->Get('defaults', 'mail_use_threads', false),
214215
'threadAlgorithm' => '',
215216
'ReplySameFolder' => (bool) $oConfig->Get('defaults', 'mail_reply_same_folder', false),
@@ -226,6 +227,7 @@ public function getAccountData(Account $oAccount): array
226227
$aResult['TrashFolder'] = (string) $oSettingsLocal->GetConf('TrashFolder', '');
227228
$aResult['ArchiveFolder'] = (string) $oSettingsLocal->GetConf('ArchiveFolder', '');
228229
$aResult['HideUnsubscribed'] = (bool) $oSettingsLocal->GetConf('HideUnsubscribed', $aResult['HideUnsubscribed']);
230+
$aResult['defaultSort'] = (string) $oSettingsLocal->GetConf('defaultSort', $aResult['defaultSort']);
229231
$aResult['useThreads'] = (bool) $oSettingsLocal->GetConf('UseThreads', $aResult['useThreads']);
230232
$aResult['threadAlgorithm'] = (string) $oSettingsLocal->GetConf('threadAlgorithm', $aResult['threadAlgorithm']);
231233
$aResult['ReplySameFolder'] = (bool) $oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);

snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public function DoSettingsUpdate() : array
204204
$this->setSettingsFromParams($oSettings, 'Resizer5Width', 'int');
205205
$this->setSettingsFromParams($oSettings, 'Resizer5Height', 'int');
206206

207+
$this->setSettingsFromParams($oSettingsLocal, 'defaultSort', 'string');
207208
$this->setSettingsFromParams($oSettingsLocal, 'UseThreads', 'bool');
208209
$this->setSettingsFromParams($oSettingsLocal, 'threadAlgorithm', 'string');
209210
$this->setSettingsFromParams($oSettingsLocal, 'ReplySameFolder', 'bool');

snappymail/v/0.0.0/app/localization/nl/user.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@
130130
"QUOTA_SIZE": "U gebruikt <strong>%SIZE% (%PROC%%)<\/strong> van <strong>%LIMIT%<\/strong>",
131131
"SORT": "Sorteren",
132132
"NO_SORT": "Mail server ondersteund sorteren niet",
133-
"SORT_ARRIVAL_ASC": "Arrived ascending",
134-
"SORT_ARRIVAL_DESC": "Arrived descending",
133+
"SORT_ARRIVAL_ASC": "Ontvangen oplopend",
134+
"SORT_ARRIVAL_DESC": "Ontvangen aflopend",
135135
"SORT_DATE_ASC": "Datum oplopend",
136136
"SORT_DATE_DESC": "Datum aflopend",
137137
"SORT_SIZE_ASC": "Grootte oplopend",

snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
<span data-bind="saveTrigger: messagesPerPageTrigger"></span>
6666
</div>
6767
</div>
68+
<div class="control-group" data-bind="visible: sortSupported">
69+
<label data-i18n="MESSAGE_LIST/SORT"></label>
70+
<select data-bind="options: sortOptions, optionsText: 'text', optionsValue: 'value', value: defaultSort"></select>
71+
<span data-bind="saveTrigger: defaultSortTrigger"></span>
72+
</div>
6873
<div class="control-group">
6974
<div>
7075
<div data-bind="component: {

0 commit comments

Comments
 (0)