diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index bd7a1bf5f9..0d099c0800 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -223,6 +223,7 @@ public function index(): TemplateResponse {
'search-priority-body' => $this->preferences->getPreference($this->currentUserId, 'search-priority-body', 'false'),
'start-mailbox-id' => $this->preferences->getPreference($this->currentUserId, 'start-mailbox-id'),
'follow-up-reminders' => $this->preferences->getPreference($this->currentUserId, 'follow-up-reminders', 'true'),
+ 'sort-favorites' => $this->preferences->getPreference($this->currentUserId, 'sort-favorites', 'false'),
]);
$this->initialStateService->provideInitialState(
'prefill_displayName',
diff --git a/src/components/AppSettingsMenu.vue b/src/components/AppSettingsMenu.vue
index 3aa108668e..eb4d9610d3 100755
--- a/src/components/AppSettingsMenu.vue
+++ b/src/components/AppSettingsMenu.vue
@@ -54,6 +54,13 @@
:label="t('mail', 'Show all messages in thread')"
:description="t('mail', 'When off, only the selected message will be shown')" />
+
+
+
@@ -348,6 +355,7 @@ export default {
internalAddressText: t('mail', 'Highlight external addresses'),
toggleAutoTagging: false,
loadingFollowUpReminders: false,
+ loadingSortFavorites: false,
displaySmimeCertificateModal: false,
sortOrder: 'newest',
showSettings: false,
@@ -384,6 +392,16 @@ export default {
return this.getAccounts.filter((account) => account && account.emailAddress)
},
+ sortFavorites: {
+ get() {
+ return this.mainStore.getPreference('sort-favorites', 'false') === 'true'
+ },
+
+ set(value) {
+ this.onToggleSortFavorites(value)
+ },
+ },
+
searchPriorityBody: {
get() {
return this.mainStore.getPreference('search-priority-body', 'false') === 'true'
@@ -564,6 +582,21 @@ export default {
}
},
+ async onToggleSortFavorites(enabled) {
+ this.loadingSortFavorites = true
+
+ try {
+ await this.mainStore.savePreference({
+ key: 'sort-favorites',
+ value: enabled ? 'true' : 'false',
+ })
+ } catch (error) {
+ Logger.error('could not save preferences', { error })
+ } finally {
+ this.loadingSortFavorites = false
+ }
+ },
+
onToggleCollectData(collect) {
this.loadingOptOutSettings = true
diff --git a/src/components/MailboxThread.vue b/src/components/MailboxThread.vue
index 4a0a49728d..3b3260836f 100644
--- a/src/components/MailboxThread.vue
+++ b/src/components/MailboxThread.vue
@@ -343,7 +343,14 @@ export default {
return envelopes.length > 0
},
+ sortFavorites() {
+ return this.mainStore.getPreference('sort-favorites', 'false') === 'true'
+ },
+
hasFavoriteEnvelopes() {
+ if (!this.sortFavorites) {
+ return false
+ }
const envelopes = this.mainStore.getEnvelopes(
this.unifiedInbox.databaseId,
this.appendToSearch(this.favoriteQuery),
@@ -424,6 +431,14 @@ export default {
}
},
+ sortFavorites(enabled) {
+ if (enabled) {
+ this.searchQuery = this.searchQuery ? 'not:starred' : this.searchQuery + ' not:starred'
+ } else if (this.searchQuery.includes('not:starred')) {
+ this.searchQuery = this.searchQuery.replace('not:starred', '')
+ }
+ },
+
async hasFollowUpEnvelopes(value) {
if (!value) {
return
@@ -444,8 +459,9 @@ export default {
},
async mounted() {
- // TODO: check the user preference
- this.searchQuery = 'not:starred'
+ if (this.sortFavorites) {
+ this.searchQuery = 'not:starred'
+ }
setTimeout(this.saveStartMailbox, START_MAILBOX_DEBOUNCE)
if (this.isThreadShown) {
await this.fetchEnvelopes()
@@ -495,8 +511,8 @@ export default {
if (this.searchQuery === undefined) {
return str
}
- // Todo: adjust once we have the user prefeference
- if (str === this.favoriteQuery && this.searchQuery.includes('not:starred')) {
+
+ if (this.sortFavorites && str === this.favoriteQuery && this.searchQuery.includes('not:starred')) {
return this.searchQuery.replace('not:starred', str)
}
return this.searchQuery + ' ' + str
diff --git a/src/init.js b/src/init.js
index 80cac5da57..6240254c9e 100644
--- a/src/init.js
+++ b/src/init.js
@@ -52,6 +52,10 @@ export default function initAfterAppCreation() {
key: 'search-priority-body',
value: preferences['search-priority-body'],
})
+ mainStore.savePreferenceMutation({
+ key: 'sort-favorites',
+ value: preferences['sort-favorites'],
+ })
const startMailboxId = preferences['start-mailbox-id']
mainStore.savePreferenceMutation({
key: 'start-mailbox-id',
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php
index 41c550f3d2..6322272c07 100644
--- a/tests/Unit/Controller/PageControllerTest.php
+++ b/tests/Unit/Controller/PageControllerTest.php
@@ -170,7 +170,7 @@ public function testIndex(): void {
$account1 = $this->createMock(Account::class);
$account2 = $this->createMock(Account::class);
$mailbox = $this->createMock(Mailbox::class);
- $this->preferences->expects($this->exactly(12))
+ $this->preferences->expects($this->exactly(13))
->method('getPreference')
->willReturnMap([
[$this->userId, 'account-settings', '[]', json_encode([])],
@@ -185,6 +185,7 @@ public function testIndex(): void {
[$this->userId, 'follow-up-reminders', 'true', 'true'],
[$this->userId, 'internal-addresses', 'false', 'false'],
[$this->userId, 'smime-sign-aliases', '[]', '[]'],
+ [$this->userId, 'sort-favorites', 'false', 'false'],
]);
$this->accountService->expects($this->once())
->method('findByUserId')
@@ -334,6 +335,7 @@ public function testIndex(): void {
'layout-mode' => 'vertical-split',
'layout-message-view' => 'threaded',
'follow-up-reminders' => 'true',
+ 'sort-favorites' => 'false'
]],
['prefill_displayName', 'Jane Doe'],
['prefill_email', 'jane@doe.cz'],