cleanup some code

This commit is contained in:
djmaze 2020-09-22 10:54:00 +02:00
parent df1d0fc8d6
commit 662e6b3466
4 changed files with 28 additions and 70 deletions

View file

@ -40,11 +40,9 @@ class LoginAdminView extends AbstractViewNext {
this.password.subscribe(() => this.passwordError(false));
this.loginError.subscribe((v) => this.loginErrorAnimation(!!v));
this.loginError.subscribe(v => this.loginErrorAnimation(!!v));
this.passwordError.subscribe((v) => {
this.passwordErrorAnimation(!!v);
});
this.passwordError.subscribe(v => this.passwordErrorAnimation(!!v));
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');

View file

@ -35,23 +35,11 @@ class DomainPopupView extends AbstractViewNext {
this.testingSieveErrorDesc = ko.observable('');
this.testingSmtpErrorDesc = ko.observable('');
this.testingImapError.subscribe((value) => {
if (!value) {
this.testingImapErrorDesc('');
}
});
this.testingImapError.subscribe(value => value || this.testingImapErrorDesc(''));
this.testingSieveError.subscribe((value) => {
if (!value) {
this.testingSieveErrorDesc('');
}
});
this.testingSieveError.subscribe(value => value || this.testingSieveErrorDesc(''));
this.testingSmtpError.subscribe((value) => {
if (!value) {
this.testingSmtpErrorDesc('');
}
});
this.testingSmtpError.subscribe(value => value || this.testingSmtpErrorDesc(''));
this.imapServerFocus = ko.observable(false);
this.sieveServerFocus = ko.observable(false);
@ -123,28 +111,20 @@ class DomainPopupView extends AbstractViewNext {
this.canBeTested = ko.computed(() => !this.testing() && this.domainIsComputed());
this.canBeSaved = ko.computed(() => !this.saving() && this.domainIsComputed());
this.page.subscribe(() => {
this.sieveSettings(false);
});
this.page.subscribe(() => this.sieveSettings(false));
// smart form improvements
this.imapServerFocus.subscribe((value) => {
if (value && this.name() && !this.imapServer()) {
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
}
});
this.imapServerFocus.subscribe(value =>
value && this.name() && !this.imapServer() && this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''))
);
this.sieveServerFocus.subscribe((value) => {
if (value && this.imapServer() && !this.sieveServer()) {
this.sieveServer(this.imapServer());
}
});
this.sieveServerFocus.subscribe(value =>
value && this.imapServer() && !this.sieveServer() && this.sieveServer(this.imapServer())
);
this.smtpServerFocus.subscribe((value) => {
if (value && this.imapServer() && !this.smtpServer()) {
this.smtpServer(this.imapServer().replace(/imap/gi, 'smtp'));
}
});
this.smtpServerFocus.subscribe(value =>
value && this.imapServer() && !this.smtpServer() && this.smtpServer(this.imapServer().replace(/imap/gi, 'smtp'))
);
this.imapSecure.subscribe((value) => {
if (this.enableSmartPorts()) {

View file

@ -79,39 +79,23 @@ class LoginUserView extends AbstractViewNext {
this.additionalCode.visibility(false);
});
this.password.subscribe(() => {
this.passwordError(false);
});
this.password.subscribe(() => this.passwordError(false));
this.additionalCode.subscribe(() => {
this.additionalCode.error(false);
});
this.additionalCode.subscribe(() => this.additionalCode.error(false));
this.additionalCode.visibility.subscribe(() => {
this.additionalCode.error(false);
});
this.additionalCode.visibility.subscribe(() => this.additionalCode.error(false));
this.emailError.subscribe((bV) => {
this.emailErrorAnimation(!!bV);
});
this.emailError.subscribe(bV => this.emailErrorAnimation(!!bV));
this.passwordError.subscribe((bV) => {
this.passwordErrorAnimation(!!bV);
});
this.passwordError.subscribe(bV => this.passwordErrorAnimation(!!bV));
this.additionalCode.error.subscribe((bV) => {
this.additionalCode.errorAnimation(!!bV);
});
this.additionalCode.error.subscribe(bV => this.additionalCode.errorAnimation(!!bV));
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.submitErrorAddidional = ko.observable('');
this.submitError.subscribe((value) => {
if (!value) {
this.submitErrorAddidional('');
}
});
this.submitError.subscribe(value => value || this.submitErrorAddidional(''));
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
@ -125,9 +109,7 @@ class LoginUserView extends AbstractViewNext {
this.signMeType = ko.observable(LoginSignMeType.Unused);
this.signMeType.subscribe((iValue) => {
this.signMe(LoginSignMeType.DefaultOn === iValue);
});
this.signMeType.subscribe(iValue => this.signMe(LoginSignMeType.DefaultOn === iValue));
this.signMeVisibility = ko.computed(() => LoginSignMeType.Unused !== this.signMeType());

View file

@ -55,13 +55,13 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
let lastEmail = '';
const createCommandReplyHelper = (type) =>
const createCommandReplyHelper = type =>
createCommand(() => {
this.lastReplyAction(type);
this.replyOrforward(type);
}, this.canBeRepliedOrForwarded);
}, this.canBeRepliedOrForwarded),
const createCommandActionHelper = (folderType, useFolder) =>
createCommandActionHelper = (folderType, useFolder) =>
createCommand(() => {
const message = this.message();
if (message && this.allowMessageListActions) {
@ -209,10 +209,8 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
this.viewFromDkimStatusTitle = ko.computed(() => {
const status = this.viewFromDkimData();
if (Array.isNotEmpty(status)) {
if (status[0] && status[1]) {
return status[1];
} else if (status[0]) {
return 'DKIM: ' + status[0];
if (status[0]) {
return status[1] || 'DKIM: ' + status[0];
}
}