mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
JavaScript string compare '' is always a ToBoolean
See https://www.ecma-international.org/ecma-262/5.1/#sec-9.2
This commit is contained in:
parent
82bed1ed80
commit
2ba34532c2
57 changed files with 213 additions and 218 deletions
|
|
@ -361,7 +361,7 @@ class AttachmentModel extends AbstractModel {
|
|||
*/
|
||||
linkThumbnailPreviewStyle() {
|
||||
const link = this.linkThumbnail();
|
||||
return '' === link ? '' : 'background:url(' + link + ')';
|
||||
return link ? 'background:url(' + link + ')' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ class ComposeAttachmentModel extends AbstractModel {
|
|||
});
|
||||
|
||||
this.title = ko.computed(() => {
|
||||
const error = this.error();
|
||||
return '' !== error ? error : this.fileName();
|
||||
return this.error() || this.fileName();
|
||||
});
|
||||
|
||||
this.friendlySize = ko.computed(() => {
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ class ContactModel extends AbstractModel {
|
|||
name = trim(property[1] + ' ' + name);
|
||||
} else if (ContactPropertyType.LastName === property[0]) {
|
||||
name = trim(name + ' ' + property[1]);
|
||||
} else if ('' === email && ContactPropertyType.Email === property[0]) {
|
||||
} else if (!email && ContactPropertyType.Email === property[0]) {
|
||||
email = property[1];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return '' === email ? null : [email, name];
|
||||
return email ? [email, name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class EmailModel {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
validate() {
|
||||
return '' !== this.name || '' !== this.email;
|
||||
return this.name || this.email;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,7 +87,7 @@ class EmailModel {
|
|||
this.dkimStatus = trim(json.DkimStatus || '');
|
||||
this.dkimValue = trim(json.DkimValue || '');
|
||||
|
||||
result = '' !== this.email;
|
||||
result = !!this.email;
|
||||
this.clearDuplicateName();
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +102,8 @@ class EmailModel {
|
|||
*/
|
||||
toLine(friendlyView, wrapWithLink = false, useEncodeHtml = false) {
|
||||
let result = '';
|
||||
if ('' !== this.email) {
|
||||
if (friendlyView && '' !== this.name) {
|
||||
if (this.email) {
|
||||
if (friendlyView && this.name) {
|
||||
result = wrapWithLink
|
||||
? '<a href="mailto:' +
|
||||
encodeHtml(this.email) +
|
||||
|
|
@ -119,7 +119,7 @@ class EmailModel {
|
|||
// '" target="_blank" tabindex="-1">' + encodeHtml(this.name) + '</a>' : (useEncodeHtml ? encodeHtml(this.name) : this.name);
|
||||
} else {
|
||||
result = this.email;
|
||||
if ('' !== this.name) {
|
||||
if (this.name) {
|
||||
if (wrapWithLink) {
|
||||
result =
|
||||
encodeHtml('"' + this.name + '" <') +
|
||||
|
|
@ -197,7 +197,7 @@ class EmailModel {
|
|||
*/
|
||||
parse(emailAddress) {
|
||||
emailAddress = trim(emailAddress);
|
||||
if ('' === emailAddress) {
|
||||
if (!emailAddress) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,13 +118,13 @@ class FilterModel extends AbstractModel {
|
|||
|
||||
this.regDisposables(
|
||||
this.name.subscribe((sValue) => {
|
||||
this.name.error('' === sValue);
|
||||
this.name.error(!sValue);
|
||||
})
|
||||
);
|
||||
|
||||
this.regDisposables(
|
||||
this.actionValue.subscribe((sValue) => {
|
||||
this.actionValue.error('' === sValue);
|
||||
this.actionValue.error(!sValue);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ class FilterModel extends AbstractModel {
|
|||
}
|
||||
|
||||
verify() {
|
||||
if ('' === this.name()) {
|
||||
if (!this.name()) {
|
||||
this.name.error(true);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ class FilterModel extends AbstractModel {
|
|||
}
|
||||
}
|
||||
|
||||
if ('' === this.actionValue()) {
|
||||
if (!this.actionValue()) {
|
||||
if ([
|
||||
FiltersAction.MoveTo,
|
||||
FiltersAction.Forward,
|
||||
|
|
@ -170,7 +170,7 @@ class FilterModel extends AbstractModel {
|
|||
|
||||
if (
|
||||
FiltersAction.Vacation === this.actionType() &&
|
||||
'' !== this.actionValueFourth() &&
|
||||
this.actionValueFourth() &&
|
||||
!this.actionValueFourth().includes('@')
|
||||
) {
|
||||
this.actionValueFourth.error(true);
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ class FilterConditionModel extends AbstractModel {
|
|||
}
|
||||
|
||||
verify() {
|
||||
if ('' === this.value()) {
|
||||
if (!this.value()) {
|
||||
this.value.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FilterConditionField.Header === this.field() && '' === this.valueSecond()) {
|
||||
if (FilterConditionField.Header === this.field() && !this.valueSecond()) {
|
||||
this.valueSecond.error(true);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class FolderModel extends AbstractModel {
|
|||
}
|
||||
}
|
||||
|
||||
if (('' !== suffix && '(' + name + ')' === suffix) || '(inbox)' === suffix.toLowerCase()) {
|
||||
if ((suffix && '(' + name + ')' === suffix) || '(inbox)' === suffix.toLowerCase()) {
|
||||
suffix = '';
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ class FolderModel extends AbstractModel {
|
|||
}
|
||||
});
|
||||
|
||||
this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && '' !== this.printableUnreadCount());
|
||||
this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && this.printableUnreadCount());
|
||||
|
||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(
|
||||
() =>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class IdentityModel extends AbstractModel {
|
|||
this.signatureInsertBefore = ko.observable(false);
|
||||
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.canBeDeleted = ko.computed(() => '' !== this.id());
|
||||
this.canBeDeleted = ko.computed(() => !!this.id());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -31,7 +31,7 @@ class IdentityModel extends AbstractModel {
|
|||
const name = this.name(),
|
||||
email = this.email();
|
||||
|
||||
return '' !== name ? name + ' (' + email + ')' : email;
|
||||
return name ? name + ' (' + email + ')' : email;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ class MessageModel extends AbstractModel {
|
|||
attachment = AttachmentModel.newInstanceFromJson(json['@Collection'][index]);
|
||||
if (attachment) {
|
||||
if (
|
||||
'' !== attachment.cidWithOutTags &&
|
||||
attachment.cidWithOutTags &&
|
||||
this.foundedCIDs.includes(attachment.cidWithOutTags)
|
||||
) {
|
||||
attachment.isLinked = true;
|
||||
|
|
@ -475,7 +475,7 @@ class MessageModel extends AbstractModel {
|
|||
'important': this.isImportant(),
|
||||
'withAttachments': this.hasAttachments(),
|
||||
'new': this.newForAnimation(),
|
||||
'emptySubject': '' === this.subject(),
|
||||
'emptySubject': !this.subject(),
|
||||
// 'hasChildrenMessage': 1 < this.threadsLen(),
|
||||
'hasUnseenSubMessage': this.hasUnseenSubMessage(),
|
||||
'hasFlaggedSubMessage': this.hasFlaggedSubMessage()
|
||||
|
|
@ -783,7 +783,7 @@ class MessageModel extends AbstractModel {
|
|||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : ';' === style.substr(-1) ? style + ' ' : style + '; ';
|
||||
style = style ? (';' === style.substr(-1) ? style + ' ' : style + '; ') : '';
|
||||
$this.attr('style', style + $this.attr(attr));
|
||||
});
|
||||
|
||||
|
|
@ -840,9 +840,9 @@ class MessageModel extends AbstractModel {
|
|||
|
||||
if (attachment && attachment.linkPreview) {
|
||||
name = $this.attr('data-x-style-cid-name');
|
||||
if ('' !== name) {
|
||||
if (name) {
|
||||
style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : ';' === style.substr(-1) ? style + ' ' : style + '; ';
|
||||
style = style ? (';' === style.substr(-1) ? style + ' ' : style + '; ') : '';
|
||||
$this.attr('style', style + name + ": url('" + attachment.linkPreview() + "')");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue