From c14d7bdd46e082c451a263368612af9720624763 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 26 Mar 2024 12:26:35 +0100 Subject: [PATCH] Add some comments and some renames --- dev/Knoin/AbstractViews.js | 10 ++++++ dev/Model/FolderCollection.js | 16 ++++----- dev/Model/Message.js | 2 +- dev/Settings/Admin/Security.js | 2 +- dev/Settings/User/General.js | 8 +++++ dev/Stores/User/Settings.js | 33 +++++++++++++++++++ .../0.0.0/app/libraries/RainLoop/Actions.php | 2 +- .../app/libraries/RainLoop/ActionsAdmin.php | 2 +- .../app/libraries/RainLoop/Model/Account.php | 22 ++++++------- .../Views/Admin/AdminSettingsSecurity.html | 2 +- .../Views/User/MailFolderListItem.html | 2 +- 11 files changed, 74 insertions(+), 27 deletions(-) diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index 43ff02b26..828318b30 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -116,6 +116,11 @@ export class AbstractViewSettings onHide() {} viewModelDom */ + /** + * When this[name] does not exists, create as observable with value of SettingsGet(name) + * When this[name+'Trigger'] does not exists, create as observable + * Subscribe to this[name], and handle saving the setting + */ addSetting(name, valueCb) { let prop = name[0].toLowerCase() + name.slice(1), @@ -131,6 +136,7 @@ export class AbstractViewSettings rl.app.Remote.saveSetting(name, value, iError => { this[trigger](iError ? SaveSettingStatus.Failed : SaveSettingStatus.Success); +// iError || Settings.set(name, value); setTimeout(() => this[trigger](SaveSettingStatus.Idle), 1000); } ); @@ -138,6 +144,10 @@ export class AbstractViewSettings }); } + /** + * Foreach name if this[name] does not exists, create as observable with value of SettingsGet(name) + * Subscribe to this[name], for saving the setting + */ addSettings(names) { names.forEach(name => { diff --git a/dev/Model/FolderCollection.js b/dev/Model/FolderCollection.js index d8d9769b0..735ea7ddc 100644 --- a/dev/Model/FolderCollection.js +++ b/dev/Model/FolderCollection.js @@ -484,16 +484,12 @@ export class FolderModel extends AbstractModel { return null; }, - hasSubscribedUnreadMessagesSubfolders: () => - !!this.subFolders().find( - folder => folder.unreadEmails() | folder.hasSubscribedUnreadMessagesSubfolders() - ) -/* - !!this.subFolders().filter( - folder => folder.unreadEmails() | folder.hasSubscribedUnreadMessagesSubfolders() - ).length -*/ - ,href: () => this.canBeSelected() && mailBox(this.fullNameHash) + hasUnreadInSub: () => + this.subFolders().some( + folder => folder.unreadEmails() | folder.hasUnreadInSub() + ), + + href: () => this.canBeSelected() && mailBox(this.fullNameHash) }); } diff --git a/dev/Model/Message.js b/dev/Model/Message.js index f03b82b18..5a0d8c08a 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -511,7 +511,7 @@ export class MessageModel extends AbstractModel { hasImages = true; }, attr = 'data-x-src', - src, useProxy = !!SettingsGet('useLocalProxyForExternalImages'); + src, useProxy = !!SettingsGet('proxyExternalImages'); body.querySelectorAll('img[' + attr + ']').forEach(node => { src = node.getAttribute(attr); if (isValid(src)) { diff --git a/dev/Settings/Admin/Security.js b/dev/Settings/Admin/Security.js index 862fe4a0f..8bcac6e48 100644 --- a/dev/Settings/Admin/Security.js +++ b/dev/Settings/Admin/Security.js @@ -10,7 +10,7 @@ export class AdminSettingsSecurity extends AbstractViewSettings { constructor() { super(); - this.addSettings(['useLocalProxyForExternalImages', 'autoVerifySignatures']); + this.addSettings(['proxyExternalImages', 'autoVerifySignatures']); this.weakPassword = rl.app.weakPassword; diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index cb1cdc73b..8fbe4ed3f 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -32,6 +32,14 @@ export class UserSettingsGeneral extends AbstractViewSettings { this.language = LanguageStore.language; this.languages = LanguageStore.languages; this.hourCycle = LanguageStore.hourCycle; +/* + // 'THREAD=REFS', 'THREAD=REFERENCES', 'THREAD=ORDEREDSUBJECT' + this.threadModes = ko.observableArray(); + AppUserStore.capabilities.forEach(capa => + capa.startsWith('THREAD=') && this.threadModes.push(capa.slice(7)) + ); + this.threadModes.sort((a, b) => a.length - b.length); +*/ this.soundNotification = SMAudio.notifications; this.notificationSound = ko.observable(SettingsGet('NotificationSound')); diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index 9c577715e..24e268b8a 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -111,6 +111,39 @@ export const SettingsUserStore = new class { 'pgpSign', 'pgpEncrypt', 'allowSpellcheck' +/* + 'MessagesPerPage', + 'MessageReadDelay', + 'SoundNotification', + 'NotificationSound', + 'DesktopNotifications', + 'Layout', + 'AutoLogout', + 'ContactsAutosave', + 'contactsAllowed', + 'CheckMailInterval', + 'SentFolder', + 'DraftsFolder', + 'JunkFolder', + 'TrashFolder', + 'ArchiveFolder', + 'hourCycle', + 'Resizer4Width', + 'Resizer5Width', + 'Resizer5Height', + 'fontSansSerif', + 'fontSerif', + 'fontMono', + 'userBackgroundName', + 'userBackgroundHash', + 'autoVerifySignatures', + 'allowLanguagesOnSettings', + 'attachmentLimit', + 'Theme', + 'language', + 'clientLanguage', + 'StaticLibsJs', +*/ ].forEach(name => { let value = SettingsGet(name); name = name[0].toLowerCase() + name.slice(1); 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 6da93ab07..047ec84fa 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -736,7 +736,7 @@ class Actions } if ($aResult['Auth']) { - $aResult['useLocalProxyForExternalImages'] = (bool)$oConfig->Get('labs', 'use_local_proxy_for_external_images', false); + $aResult['proxyExternalImages'] = (bool)$oConfig->Get('labs', 'use_local_proxy_for_external_images', false); $aResult['autoVerifySignatures'] = (bool)$oConfig->Get('security', 'auto_verify_signatures', false); $aResult['allowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true); $aResult['Capa'] = $this->Capa($bAdmin, $oAccount); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php index 267ff0c11..f6d4fe875 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php @@ -64,7 +64,7 @@ class ActionsAdmin extends Actions return $self->ValidateTheme($sTheme); }); - $this->setConfigFromParams($oConfig, 'useLocalProxyForExternalImages', 'labs', 'use_local_proxy_for_external_images', 'bool'); + $this->setConfigFromParams($oConfig, 'proxyExternalImages', 'labs', 'use_local_proxy_for_external_images', 'bool'); $this->setConfigFromParams($oConfig, 'autoVerifySignatures', 'security', 'auto_verify_signatures', 'bool'); $this->setConfigFromParams($oConfig, 'allowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool'); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php index 6f55b8ba7..d8d76e4a6 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Account.php @@ -17,9 +17,9 @@ abstract class Account implements \JsonSerializable private ?SensitiveString $oPassword = null; - private string $sSmtpLogin = ''; + private string $sSmtpUser = ''; - private ?SensitiveString $oSmtpPassword = null; + private ?SensitiveString $oSmtpPass = null; private Domain $oDomain; @@ -46,8 +46,8 @@ abstract class Account implements \JsonSerializable public function OutLogin() : string { -// return $this->oDomain->SmtpSettings()->fixUsername($this->sSmtpLogin ?: $this->sEmail); - return $this->sSmtpLogin ?: $this->sEmail; +// return $this->oDomain->SmtpSettings()->fixUsername($this->sSmtpUser ?: $this->sEmail); + return $this->sSmtpUser ?: $this->sEmail; } public function Domain() : Domain @@ -72,7 +72,7 @@ abstract class Account implements \JsonSerializable public function SetSmtpPassword(SensitiveString $oPassword) : void { - $this->oSmtpPassword = $oPassword; + $this->oSmtpPass = $oPassword; } #[\ReturnTypeWillChange] @@ -84,10 +84,10 @@ abstract class Account implements \JsonSerializable 'pass' => $this->IncPassword(), 'name' => $this->sName ]; - if ($this->sSmtpLogin && $this->oSmtpPassword) { + if ($this->sSmtpUser && $this->oSmtpPass) { $result['smtp'] = [ - 'user' => $this->sSmtpLogin, - 'pass' => $this->oSmtpPassword->getValue() + 'user' => $this->sSmtpUser, + 'pass' => $this->oSmtpPass->getValue() ]; } return $result; @@ -165,7 +165,7 @@ abstract class Account implements \JsonSerializable } // init smtp user/password if (isset($aAccountHash['smtp'])) { - $oAccount->sSmtpLogin = $aAccountHash['smtp']['user']; + $oAccount->sSmtpUser = $aAccountHash['smtp']['user']; $oAccount->SetSmtpPassword(new SensitiveString($aAccountHash['smtp']['pass'])); } } @@ -214,11 +214,11 @@ abstract class Account implements \JsonSerializable $oSmtpClient->Connect($oSettings); $oPlugins->RunHook('smtp.after-connect', array($this, $oSmtpClient, $oSettings)); /* - if ($this->oDomain->OutAskCredentials() && !($this->oSmtpPassword && $this->sSmtpLogin)) { + if ($this->oDomain->OutAskCredentials() && !($this->oSmtpPass && $this->sSmtpUser)) { throw new RequireCredentialsException } */ - $oSettings->passphrase = $this->oSmtpPassword ?: $this->oPassword; + $oSettings->passphrase = $this->oSmtpPass ?: $this->oPassword; return $this->netClientLogin($oSmtpClient, $oPlugins); } diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html index ce8aa0937..3b95f19e1 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html @@ -5,7 +5,7 @@ name: 'Checkbox', params: { label: 'TAB_SECURITY/LABEL_USE_IMAGE_PROXY', - value: useLocalProxyForExternalImages + value: proxyExternalImages } }"> diff --git a/snappymail/v/0.0.0/app/templates/Views/User/MailFolderListItem.html b/snappymail/v/0.0.0/app/templates/Views/User/MailFolderListItem.html index 686c2e049..35bb12f22 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/MailFolderListItem.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/MailFolderListItem.html @@ -1,6 +1,6 @@