Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public function index(): TemplateResponse {
'sort-favorites' => $this->preferences->getPreference($this->userId, 'sort-favorites', 'false'),
'index-context-chat' => $this->contextChatSettingsService->isIndexingEnabled($this->userId) ? 'true' : 'false',
'compact-mode' => $this->preferences->getPreference($this->userId, 'compact-mode', 'false'),
'auto-mark-as-read' => $this->preferences->getPreference($this->userId, 'auto-mark-as-read', 'true'),
]);
$this->initialStateService->provideInitialState(
'prefill_displayName',
Expand Down
33 changes: 33 additions & 0 deletions src/components/AppSettingsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
:disabled="loadingPrioritySettings">
{{ prioritySettingsText }}
</NcFormBoxSwitch>

<NcFormBoxSwitch
v-model="autoMarkAsRead"
:disabled="loadingAutoMarkAsRead">
{{ t('mail', 'Automatically mark messages as read when opened') }}
</NcFormBoxSwitch>
</NcFormBox>

<NcRadioGroup :model-value="useBottomReplies" :label="t('mail', 'Reply position')" @update:modelValue="onToggleButtonReplies">
Expand Down Expand Up @@ -372,6 +378,7 @@ export default {
loadingAvatarSettings: false,
prioritySettingsText: t('mail', 'Search the body of messages in priority Inbox'),
loadingPrioritySettings: false,
loadingAutoMarkAsRead: false,

optOutSettingsText: t('mail', 'Activate'),
loadingOptOutSettings: false,
Expand Down Expand Up @@ -451,6 +458,16 @@ export default {
},
},

autoMarkAsRead: {
get() {
return this.mainStore.getPreference('auto-mark-as-read', 'true') === 'true'
},

set(value) {
this.onToggleAutoMarkAsRead(value)
},
},

useExternalAvatars: {
get() {
return this.mainStore.getPreference('external-avatars', 'true') === 'true'
Expand Down Expand Up @@ -652,6 +669,22 @@ export default {
}
},

async onToggleAutoMarkAsRead(enabled) {
this.loadingAutoMarkAsRead = true

try {
await this.mainStore.savePreference({
key: 'auto-mark-as-read',
value: enabled ? 'true' : 'false',
})
} catch (error) {
Logger.error('could not save preferences', { error })
showError(t('mail', 'Could not update preference'))
} finally {
this.loadingAutoMarkAsRead = false
}
},

async onToggleSortFavorites(enabled) {
this.loadingSortFavorites = true

Expand Down
3 changes: 2 additions & 1 deletion src/components/ThreadEnvelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,8 @@ export default {
clearTimeout(loadingTimeout)
}

if (!this.envelope.flags.seen && this.hasSeenAcl) {
const autoMarkAsRead = this.mainStore.getPreference('auto-mark-as-read', 'true') === 'true'
if (autoMarkAsRead && !this.envelope.flags.seen && this.hasSeenAcl) {
logger.info('Starting timer to mark message as seen/read')
this.seenTimer = setTimeout(() => {
this.mainStore.toggleEnvelopeSeen({ envelope: this.envelope })
Expand Down
4 changes: 4 additions & 0 deletions src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export default function initAfterAppCreation() {
key: 'compact-mode',
value: preferences['compact-mode'],
})
mainStore.savePreferenceMutation({
key: 'auto-mark-as-read',
value: preferences['auto-mark-as-read'],
})

mainStore.setQuickActions(loadState('mail', 'quick-actions', []))

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Controller/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function testIndex(): void {
$account1 = $this->createMock(Account::class);
$account2 = $this->createMock(Account::class);
$mailbox = $this->createStub(Mailbox::class);
$this->preferences->expects($this->exactly(14))
$this->preferences->expects($this->exactly(15))
->method('getPreference')
->willReturnMap([
[$this->userId, 'account-settings', '[]', json_encode([])],
Expand All @@ -197,6 +197,7 @@ public function testIndex(): void {
[$this->userId, 'smime-sign-aliases', '[]', '[]'],
[$this->userId, 'sort-favorites', 'false', 'false'],
[$this->userId, 'compact-mode', 'false', 'false'],
[$this->userId, 'auto-mark-as-read', 'true', 'true'],
]);
$this->accountService->expects($this->once())
->method('findByUserId')
Expand Down