From 7c75e116665aebbe99616a858a2bc6d3f64a4b78 Mon Sep 17 00:00:00 2001 From: djmaze Date: Thu, 2 Sep 2021 14:21:50 +0200 Subject: [PATCH] Resolve issue #138 --- dev/Settings/User/General.js | 5 ++ dev/Stores/User/Message.js | 69 +++++++++---------- dev/Stores/User/Settings.js | 5 +- .../0.0.0/app/libraries/RainLoop/Actions.php | 2 + .../app/libraries/RainLoop/Actions/User.php | 1 + .../libraries/RainLoop/Config/Application.php | 1 + .../v/0.0.0/app/localization/de-DE/user.json | 2 + .../v/0.0.0/app/localization/en/user.json | 2 + .../v/0.0.0/app/localization/es-ES/user.json | 2 + .../v/0.0.0/app/localization/fr-FR/user.json | 2 + .../v/0.0.0/app/localization/hu-HU/user.json | 2 + .../v/0.0.0/app/localization/nl-NL/user.json | 2 + .../v/0.0.0/app/localization/sv-SE/user.json | 2 + .../v/0.0.0/app/localization/zh-CN/user.json | 2 + .../templates/Views/User/SettingsGeneral.html | 9 +++ 15 files changed, 71 insertions(+), 37 deletions(-) diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index bbf225b17..386044dd2 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -25,6 +25,7 @@ export class GeneralUserSettings { constructor() { this.language = LanguageStore.language; this.languages = LanguageStore.languages; + this.messageReadDelay = SettingsUserStore.messageReadDelay; this.messagesPerPage = SettingsUserStore.messagesPerPage; this.messagesPerPageArray = MESSAGES_PER_PAGE_VALUES; @@ -51,6 +52,7 @@ export class GeneralUserSettings { addObservablesTo(this, { mppTrigger: SaveSettingsStep.Idle, + messageReadDelayTrigger: SaveSettingsStep.Idle, editorDefaultTypeTrigger: SaveSettingsStep.Idle, layoutTrigger: SaveSettingsStep.Idle }); @@ -102,6 +104,9 @@ export class GeneralUserSettings { editorDefaultType: value => Remote.saveSetting('EditorDefaultType', value, settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this)), + messageReadDelay: value => Remote.saveSetting('MessageReadDelay', value, + settingsSaveHelperSimpleFunction(this.messageReadDelayTrigger, this)), + messagesPerPage: value => Remote.saveSetting('MPP', value, settingsSaveHelperSimpleFunction(this.mppTrigger, this)), diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 408cd5bd0..c7d008ab2 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -3,7 +3,7 @@ import ko from 'ko'; import { Scope, Notification } from 'Common/Enums'; import { MessageSetAction } from 'Common/EnumsUser'; import { doc, $htmlCL, createElement, elementById } from 'Common/Globals'; -import { arrayLength, pInt, pString, addObservablesTo, addSubscribablesTo } from 'Common/Utils'; +import { arrayLength, pInt, pString, addObservablesTo, addComputablesTo, addSubscribablesTo } from 'Common/Utils'; import { plainToHtml } from 'Common/UtilsUser'; import { @@ -111,30 +111,46 @@ export const MessageUserStore = new class { // Computed Observables - this.listEndHash = ko.computed( - () => + addComputablesTo(this, { + listEndHash: () => this.listEndFolder() + '|' + this.listEndSearch() + '|' + this.listEndThreadUid() + '|' + - this.listEndPage() - ); + this.listEndPage(), - this.listPageCount = ko.computed(() => - Math.max(1, Math.ceil(this.listCount() / SettingsUserStore.messagesPerPage())) - ); + listPageCount: () => Math.max(1, Math.ceil(this.listCount() / SettingsUserStore.messagesPerPage())), - this.mainMessageListSearch = ko.computed({ - read: this.listSearch, - write: value => - rl.route.setHash( + mainMessageListSearch: { + read: this.listSearch, + write: value => rl.route.setHash( mailBox(FolderUserStore.currentFolderFullNameHash(), 1, value.toString().trim(), this.listThreadUid()) ) - }); + }, - this.isMessageSelected = ko.computed(() => null !== this.message()); + isMessageSelected: () => null !== this.message(), + + listCheckedOrSelected: () => { + const + selectedMessage = this.selectorMessageSelected(), + focusedMessage = this.selectorMessageFocused(), + checked = this.list.filter(item => isChecked(item) || item === selectedMessage); + return checked.length ? checked : (focusedMessage ? [focusedMessage] : []); + }, + + listCheckedOrSelectedUidsWithSubMails: () => { + let result = []; + this.listCheckedOrSelected().forEach(message => { + result.push(message.uid); + if (1 < message.threadsLen()) { + result = result.concat(message.threads()).unique(); + } + }); + return result; + } + }); this.listChecked = ko .computed(() => this.list.filter(isChecked)) @@ -150,25 +166,6 @@ export const MessageUserStore = new class { || this.list.find(item => item.checked()))) .extend({ rateLimit: 50 }); - this.listCheckedOrSelected = ko.computed(() => { - const - selectedMessage = this.selectorMessageSelected(), - focusedMessage = this.selectorMessageFocused(), - checked = this.list.filter(item => isChecked(item) || item === selectedMessage); - return checked.length ? checked : (focusedMessage ? [focusedMessage] : []); - }); - - this.listCheckedOrSelectedUidsWithSubMails = ko.computed(() => { - let result = []; - this.listCheckedOrSelected().forEach(message => { - result.push(message.uid); - if (1 < message.threadsLen()) { - result = result.concat(message.threads()).unique(); - } - }); - return result; - }); - // Subscribers let timer = 0, fn = this.listLoadingAnimation; @@ -470,7 +467,7 @@ export const MessageUserStore = new class { if (messagesDom) { let body = null, - id = 'rl-mgs-' + message.hash.replace(/[^a-zA-Z0-9]/g, ''); + id = 'rl-msg-' + message.hash.replace(/[^a-zA-Z0-9]/g, ''); const textBody = elementById(id); if (textBody) { @@ -557,10 +554,10 @@ export const MessageUserStore = new class { } MessageFlagsCache.initMessage(message); - if (message.isUnseen() || message.hasUnseenSubMessage()) { + if (message.isUnseen()) { MessageSeenTimer = setTimeout( () => rl.app.messageListAction(message.folder, MessageSetAction.SetSeen, [message]), - 5000 // 5 seconds + SettingsUserStore.messageReadDelay() * 1000 // seconds ); } diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index d3b20fd73..5d46beef5 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -23,6 +23,10 @@ export const SettingsUserStore = new class { this.messagesPerPage = ko.observable(SettingsGet('MPP')).extend({ limitedList: MESSAGES_PER_PAGE_VALUES }); + this.messageReadDelay = ko.observable(pInt(SettingsGet('MessageReadDelay'))).extend( + { rateLimit: { timeout: 500, method: "notifyWhenChangesStop" } } + ); + addObservablesTo(this, { showImages: !!SettingsGet('ShowImages'), removeColors: !!SettingsGet('RemoveColors'), @@ -31,7 +35,6 @@ export const SettingsUserStore = new class { useThreads: !!SettingsGet('UseThreads'), replySameFolder: !!SettingsGet('ReplySameFolder'), hideUnsubscribed: !!SettingsGet('HideUnsubscribed'), - autoLogout: pInt(SettingsGet('AutoLogout')) }); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index 66d7781b4..bf5818e16 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1057,6 +1057,7 @@ class Actions 'ShowImages' => (bool) $oConfig->Get('defaults', 'show_images', false), 'RemoveColors' => (bool) $oConfig->Get('defaults', 'remove_colors', false), 'MPP' => (int) $oConfig->Get('webmail', 'messages_per_page', 25), + 'MessageReadDelay' => (int) $oConfig->Get('webmail', 'message_read_delay', 5), 'SoundNotification' => false, 'NotificationSound' => 'new-mail', 'DesktopNotifications' => false, @@ -1163,6 +1164,7 @@ class Actions $aResult['RemoveColors'] = (bool)$oSettings->GetConf('RemoveColors', $aResult['RemoveColors']); $aResult['ContactsAutosave'] = (bool)$oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']); $aResult['MPP'] = (int)$oSettings->GetConf('MPP', $aResult['MPP']); + $aResult['MessageReadDelay'] = (int)$oSettings->GetConf('MessageReadDelay', $aResult['MessageReadDelay']); $aResult['SoundNotification'] = (bool)$oSettings->GetConf('SoundNotification', $aResult['SoundNotification']); $aResult['NotificationSound'] = (string)$oSettings->GetConf('NotificationSound', $aResult['NotificationSound']); $aResult['DesktopNotifications'] = (bool)$oSettings->GetConf('DesktopNotifications', $aResult['DesktopNotifications']); 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 f79671357..b4cde251c 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 @@ -351,6 +351,7 @@ trait User $this->setSettingsFromParams($oSettings, 'UseCheckboxesInList', 'bool'); $this->setSettingsFromParams($oSettings, 'AllowDraftAutosave', 'bool'); $this->setSettingsFromParams($oSettings, 'AutoLogout', 'int'); + $this->setSettingsFromParams($oSettings, 'MessageReadDelay', 'int'); $this->setSettingsFromParams($oSettingsLocal, 'UseThreads', 'bool'); $this->setSettingsFromParams($oSettingsLocal, 'ReplySameFolder', 'bool'); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index f7276d522..e50cf2e83 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -135,6 +135,7 @@ class Application extends \RainLoop\Config\AbstractConfig 'allow_additional_identities' => array(true, ''), 'messages_per_page' => array(20, 'Number of messages displayed on page by default'), + 'message_read_delay' => array(5, 'Mark message read after N seconds'), 'attachment_size_limit' => array(\min($upload_max_filesize, 25), 'File size limit (MB) for file upload on compose screen 0 for unlimited.') diff --git a/snappymail/v/0.0.0/app/localization/de-DE/user.json b/snappymail/v/0.0.0/app/localization/de-DE/user.json index 4995fc1e5..ce2ac11c2 100644 --- a/snappymail/v/0.0.0/app/localization/de-DE/user.json +++ b/snappymail/v/0.0.0/app/localization/de-DE/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "In der Nachricht enthaltene Bilder immer anzeigen", "LABEL_REMOVE_COLORS": "Entferne Hintergrund- und Textfarben aus der Nachricht", "LABEL_MESSAGE_PER_PAGE": "Nachrichten pro Seite", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Benachrichtigungen", "LABEL_SOUND_NOTIFICATION": "Benachrichtigungston", "LABEL_CHROME_NOTIFICATION_DESC": "Popups einblenden, wenn neue Nachrichten vorhanden sind", diff --git a/snappymail/v/0.0.0/app/localization/en/user.json b/snappymail/v/0.0.0/app/localization/en/user.json index c27ecb576..cd089d89f 100644 --- a/snappymail/v/0.0.0/app/localization/en/user.json +++ b/snappymail/v/0.0.0/app/localization/en/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "Always display external images in message body", "LABEL_REMOVE_COLORS": "Remove background and text colors from message body", "LABEL_MESSAGE_PER_PAGE": "Messages on page", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Notifications", "LABEL_SOUND_NOTIFICATION": "Sound notification", "LABEL_CHROME_NOTIFICATION_DESC": "Show new messages notification popups", diff --git a/snappymail/v/0.0.0/app/localization/es-ES/user.json b/snappymail/v/0.0.0/app/localization/es-ES/user.json index daa30d7ed..32607eb19 100644 --- a/snappymail/v/0.0.0/app/localization/es-ES/user.json +++ b/snappymail/v/0.0.0/app/localization/es-ES/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "Mostrar siempre las imágenes en el cuerpo del mensaje", "LABEL_REMOVE_COLORS": "Eliminar el fondo y los colores del texto del mensaje", "LABEL_MESSAGE_PER_PAGE": "Mensajes en página", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Notificaciones", "LABEL_SOUND_NOTIFICATION": "Sonido de la notificación", "LABEL_CHROME_NOTIFICATION_DESC": "Mostrar notificación de nuevos mensajes en Popup", diff --git a/snappymail/v/0.0.0/app/localization/fr-FR/user.json b/snappymail/v/0.0.0/app/localization/fr-FR/user.json index 6d261734d..05309acd8 100644 --- a/snappymail/v/0.0.0/app/localization/fr-FR/user.json +++ b/snappymail/v/0.0.0/app/localization/fr-FR/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "Toujours afficher les images dans le mail", "LABEL_REMOVE_COLORS": "Supprimer les couleurs d'arrière-plan et de texte du message", "LABEL_MESSAGE_PER_PAGE": "Messages par page", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Notifications", "LABEL_SOUND_NOTIFICATION": "Son de notification", "LABEL_CHROME_NOTIFICATION_DESC": "Afficher un pop-up de notification pour les nouveaux messages", diff --git a/snappymail/v/0.0.0/app/localization/hu-HU/user.json b/snappymail/v/0.0.0/app/localization/hu-HU/user.json index 997cbd0c0..bdbc30758 100644 --- a/snappymail/v/0.0.0/app/localization/hu-HU/user.json +++ b/snappymail/v/0.0.0/app/localization/hu-HU/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "Mindig jelenítse meg a külső képeket az üzenet törzsében", "LABEL_REMOVE_COLORS": "Remove background and text colors from message body", "LABEL_MESSAGE_PER_PAGE": "Üzenetek egy oldalon", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Értesítések", "LABEL_SOUND_NOTIFICATION": "Hangos értesítés", "LABEL_CHROME_NOTIFICATION_DESC": "Új üzenetek értesítő ablakainak megjelenítése", diff --git a/snappymail/v/0.0.0/app/localization/nl-NL/user.json b/snappymail/v/0.0.0/app/localization/nl-NL/user.json index 1e85a64c7..7046fab2b 100644 --- a/snappymail/v/0.0.0/app/localization/nl-NL/user.json +++ b/snappymail/v/0.0.0/app/localization/nl-NL/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "Afbeeldingen altijd weergeven in het bericht", "LABEL_REMOVE_COLORS": "Verwijder achtergrond- en tekstkleuren uit het bericht", "LABEL_MESSAGE_PER_PAGE": "Berichten op pagina", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Notificaties", "LABEL_SOUND_NOTIFICATION": "Notificatie geluid", "LABEL_CHROME_NOTIFICATION_DESC": "Toon nieuwe berichten popup", diff --git a/snappymail/v/0.0.0/app/localization/sv-SE/user.json b/snappymail/v/0.0.0/app/localization/sv-SE/user.json index 5aa7f2418..156bec6cc 100644 --- a/snappymail/v/0.0.0/app/localization/sv-SE/user.json +++ b/snappymail/v/0.0.0/app/localization/sv-SE/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "Visa alltid bilder i mail", "LABEL_REMOVE_COLORS": "Remove background and text colors from message body", "LABEL_MESSAGE_PER_PAGE": "Meddelanden per sida", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "Aviseringar", "LABEL_SOUND_NOTIFICATION": "Ljudnotifikation", "LABEL_CHROME_NOTIFICATION_DESC": "Visa nya meddelande-aviseringar som popup-fönster", diff --git a/snappymail/v/0.0.0/app/localization/zh-CN/user.json b/snappymail/v/0.0.0/app/localization/zh-CN/user.json index ecfdd4cea..381831285 100644 --- a/snappymail/v/0.0.0/app/localization/zh-CN/user.json +++ b/snappymail/v/0.0.0/app/localization/zh-CN/user.json @@ -397,6 +397,8 @@ "LABEL_SHOW_IMAGES": "总是显示外部图片信息", "LABEL_REMOVE_COLORS": "从消息中删除背景和文本颜色", "LABEL_MESSAGE_PER_PAGE": "封邮件每页", + "LABEL_MARK_MESSAGE_READ_AFTER": "Mark message as read after", + "SECONDS": "seconds", "LABEL_NOTIFICATIONS": "通知", "LABEL_SOUND_NOTIFICATION": "提示音", "LABEL_CHROME_NOTIFICATION_DESC": "显示新邮件弹窗", 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 e1669a602..2d37ca3d7 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 @@ -62,6 +62,15 @@ }"> +
+ +
+ +   + + +
+