Add some comments and some renames

This commit is contained in:
the-djmaze 2024-03-26 12:26:35 +01:00
parent 25214f2d87
commit c14d7bdd46
11 changed files with 74 additions and 27 deletions

View file

@ -116,6 +116,11 @@ export class AbstractViewSettings
onHide() {} onHide() {}
viewModelDom 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) addSetting(name, valueCb)
{ {
let prop = name[0].toLowerCase() + name.slice(1), let prop = name[0].toLowerCase() + name.slice(1),
@ -131,6 +136,7 @@ export class AbstractViewSettings
rl.app.Remote.saveSetting(name, value, rl.app.Remote.saveSetting(name, value,
iError => { iError => {
this[trigger](iError ? SaveSettingStatus.Failed : SaveSettingStatus.Success); this[trigger](iError ? SaveSettingStatus.Failed : SaveSettingStatus.Success);
// iError || Settings.set(name, value);
setTimeout(() => this[trigger](SaveSettingStatus.Idle), 1000); 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) addSettings(names)
{ {
names.forEach(name => { names.forEach(name => {

View file

@ -484,16 +484,12 @@ export class FolderModel extends AbstractModel {
return null; return null;
}, },
hasSubscribedUnreadMessagesSubfolders: () => hasUnreadInSub: () =>
!!this.subFolders().find( this.subFolders().some(
folder => folder.unreadEmails() | folder.hasSubscribedUnreadMessagesSubfolders() folder => folder.unreadEmails() | folder.hasUnreadInSub()
) ),
/*
!!this.subFolders().filter( href: () => this.canBeSelected() && mailBox(this.fullNameHash)
folder => folder.unreadEmails() | folder.hasSubscribedUnreadMessagesSubfolders()
).length
*/
,href: () => this.canBeSelected() && mailBox(this.fullNameHash)
}); });
} }

View file

@ -511,7 +511,7 @@ export class MessageModel extends AbstractModel {
hasImages = true; hasImages = true;
}, },
attr = 'data-x-src', attr = 'data-x-src',
src, useProxy = !!SettingsGet('useLocalProxyForExternalImages'); src, useProxy = !!SettingsGet('proxyExternalImages');
body.querySelectorAll('img[' + attr + ']').forEach(node => { body.querySelectorAll('img[' + attr + ']').forEach(node => {
src = node.getAttribute(attr); src = node.getAttribute(attr);
if (isValid(src)) { if (isValid(src)) {

View file

@ -10,7 +10,7 @@ export class AdminSettingsSecurity extends AbstractViewSettings {
constructor() { constructor() {
super(); super();
this.addSettings(['useLocalProxyForExternalImages', 'autoVerifySignatures']); this.addSettings(['proxyExternalImages', 'autoVerifySignatures']);
this.weakPassword = rl.app.weakPassword; this.weakPassword = rl.app.weakPassword;

View file

@ -32,6 +32,14 @@ export class UserSettingsGeneral extends AbstractViewSettings {
this.language = LanguageStore.language; this.language = LanguageStore.language;
this.languages = LanguageStore.languages; this.languages = LanguageStore.languages;
this.hourCycle = LanguageStore.hourCycle; 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.soundNotification = SMAudio.notifications;
this.notificationSound = ko.observable(SettingsGet('NotificationSound')); this.notificationSound = ko.observable(SettingsGet('NotificationSound'));

View file

@ -111,6 +111,39 @@ export const SettingsUserStore = new class {
'pgpSign', 'pgpSign',
'pgpEncrypt', 'pgpEncrypt',
'allowSpellcheck' '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 => { ].forEach(name => {
let value = SettingsGet(name); let value = SettingsGet(name);
name = name[0].toLowerCase() + name.slice(1); name = name[0].toLowerCase() + name.slice(1);

View file

@ -736,7 +736,7 @@ class Actions
} }
if ($aResult['Auth']) { 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['autoVerifySignatures'] = (bool)$oConfig->Get('security', 'auto_verify_signatures', false);
$aResult['allowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true); $aResult['allowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true);
$aResult['Capa'] = $this->Capa($bAdmin, $oAccount); $aResult['Capa'] = $this->Capa($bAdmin, $oAccount);

View file

@ -64,7 +64,7 @@ class ActionsAdmin extends Actions
return $self->ValidateTheme($sTheme); 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, 'autoVerifySignatures', 'security', 'auto_verify_signatures', 'bool');
$this->setConfigFromParams($oConfig, 'allowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool'); $this->setConfigFromParams($oConfig, 'allowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');

View file

@ -17,9 +17,9 @@ abstract class Account implements \JsonSerializable
private ?SensitiveString $oPassword = null; private ?SensitiveString $oPassword = null;
private string $sSmtpLogin = ''; private string $sSmtpUser = '';
private ?SensitiveString $oSmtpPassword = null; private ?SensitiveString $oSmtpPass = null;
private Domain $oDomain; private Domain $oDomain;
@ -46,8 +46,8 @@ abstract class Account implements \JsonSerializable
public function OutLogin() : string public function OutLogin() : string
{ {
// return $this->oDomain->SmtpSettings()->fixUsername($this->sSmtpLogin ?: $this->sEmail); // return $this->oDomain->SmtpSettings()->fixUsername($this->sSmtpUser ?: $this->sEmail);
return $this->sSmtpLogin ?: $this->sEmail; return $this->sSmtpUser ?: $this->sEmail;
} }
public function Domain() : Domain public function Domain() : Domain
@ -72,7 +72,7 @@ abstract class Account implements \JsonSerializable
public function SetSmtpPassword(SensitiveString $oPassword) : void public function SetSmtpPassword(SensitiveString $oPassword) : void
{ {
$this->oSmtpPassword = $oPassword; $this->oSmtpPass = $oPassword;
} }
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@ -84,10 +84,10 @@ abstract class Account implements \JsonSerializable
'pass' => $this->IncPassword(), 'pass' => $this->IncPassword(),
'name' => $this->sName 'name' => $this->sName
]; ];
if ($this->sSmtpLogin && $this->oSmtpPassword) { if ($this->sSmtpUser && $this->oSmtpPass) {
$result['smtp'] = [ $result['smtp'] = [
'user' => $this->sSmtpLogin, 'user' => $this->sSmtpUser,
'pass' => $this->oSmtpPassword->getValue() 'pass' => $this->oSmtpPass->getValue()
]; ];
} }
return $result; return $result;
@ -165,7 +165,7 @@ abstract class Account implements \JsonSerializable
} }
// init smtp user/password // init smtp user/password
if (isset($aAccountHash['smtp'])) { if (isset($aAccountHash['smtp'])) {
$oAccount->sSmtpLogin = $aAccountHash['smtp']['user']; $oAccount->sSmtpUser = $aAccountHash['smtp']['user'];
$oAccount->SetSmtpPassword(new SensitiveString($aAccountHash['smtp']['pass'])); $oAccount->SetSmtpPassword(new SensitiveString($aAccountHash['smtp']['pass']));
} }
} }
@ -214,11 +214,11 @@ abstract class Account implements \JsonSerializable
$oSmtpClient->Connect($oSettings); $oSmtpClient->Connect($oSettings);
$oPlugins->RunHook('smtp.after-connect', array($this, $oSmtpClient, $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 throw new RequireCredentialsException
} }
*/ */
$oSettings->passphrase = $this->oSmtpPassword ?: $this->oPassword; $oSettings->passphrase = $this->oSmtpPass ?: $this->oPassword;
return $this->netClientLogin($oSmtpClient, $oPlugins); return $this->netClientLogin($oSmtpClient, $oPlugins);
} }

View file

@ -5,7 +5,7 @@
name: 'Checkbox', name: 'Checkbox',
params: { params: {
label: 'TAB_SECURITY/LABEL_USE_IMAGE_PROXY', label: 'TAB_SECURITY/LABEL_USE_IMAGE_PROXY',
value: useLocalProxyForExternalImages value: proxyExternalImages
} }
}"></div> }"></div>
</div> </div>

View file

@ -1,6 +1,6 @@
<li> <li>
<a data-bind="dropmessages: $data, <a data-bind="dropmessages: $data,
css: { 'selected': selected() && !isSystemFolder(), 'system': isSystemFolder, 'selectable': canBeSelected, 'unread-sub': hasSubscribedUnreadMessagesSubfolders, 'anim-action-class': actionBlink }, css: { 'selected': selected() && !isSystemFolder(), 'system': isSystemFolder, 'selectable': canBeSelected, 'unread-sub': hasUnreadInSub, 'anim-action-class': actionBlink },
attr: { 'data-unread': unreadCount, href: href }"> attr: { 'data-unread': unreadCount, href: href }">
<i data-bind="css: collapsedCss()"></i> <i data-bind="css: collapsedCss()"></i>
<!-- ko text: name --><!-- /ko --> <!-- ko text: name --><!-- /ko -->