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

Commit

Permalink
Added setting for default messages sort mode
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Oct 10, 2024
1 parent 16106a2 commit 055c0d3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 5 deletions.
49 changes: 47 additions & 2 deletions dev/Settings/User/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,60 @@ 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();
FolderUserStore.capabilities.forEach(capa =>
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',
Expand Down Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion dev/Stores/User/Folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -59,7 +60,7 @@ FolderUserStore = new class {
*/
displaySpecSetting: false,

sortMode: '',
sortMode: SettingsUserStore.defaultSort(),

quotaLimit: 0,
quotaUsage: 0,
Expand Down
2 changes: 2 additions & 0 deletions dev/Stores/User/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const SettingsUserStore = new class {
showNextMessage: 0,
allowDraftAutosave: 1,
useThreads: 0,
defaultSort: '',
threadAlgorithm: '',
replySameFolder: 0,
hideUnsubscribed: 0,
Expand Down Expand Up @@ -103,6 +104,7 @@ export const SettingsUserStore = new class {
'showNextMessage',
'AllowDraftAutosave',
'useThreads',
'defaultSort',
'threadAlgorithm',
'ReplySameFolder',
'HideUnsubscribed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public function getAccountData(Account $oAccount): array
'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),
Expand All @@ -226,6 +227,7 @@ public function getAccountData(Account $oAccount): array
$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']);
Expand Down
1 change: 1 addition & 0 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function DoSettingsUpdate() : array
$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');
Expand Down
4 changes: 2 additions & 2 deletions snappymail/v/0.0.0/app/localization/nl/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
"QUOTA_SIZE": "U gebruikt <strong>%SIZE% (%PROC%%)<\/strong> van <strong>%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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
<span data-bind="saveTrigger: messagesPerPageTrigger"></span>
</div>
</div>
<div class="control-group" data-bind="visible: sortSupported">
<label data-i18n="MESSAGE_LIST/SORT"></label>
<select data-bind="options: sortOptions, optionsText: 'text', optionsValue: 'value', value: defaultSort"></select>
<span data-bind="saveTrigger: defaultSortTrigger"></span>
</div>
<div class="control-group">
<div>
<div data-bind="component: {
Expand Down

0 comments on commit 055c0d3

Please sign in to comment.