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:
djmaze 2020-07-28 17:20:14 +02:00
parent 82bed1ed80
commit 2ba34532c2
57 changed files with 213 additions and 218 deletions

View file

@ -102,7 +102,7 @@ class ContactsAdminSettings {
this.onTestContactsResponse = this.onTestContactsResponse.bind(this);
}
@command((self) => '' !== self.pdoDsn() && '' !== self.pdoUser())
@command((self) => self.pdoDsn() && self.pdoUser())
testContactsCommand() {
this.testContactsSuccess(false);
this.testContactsError(false);

View file

@ -18,13 +18,13 @@ class PackagesAdminSettings {
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
this.packagesCurrent = ko.computed(() =>
this.packages().filter(item => item && '' !== item.installed && !item.compare)
this.packages().filter(item => item && item.installed && !item.compare)
);
this.packagesAvailableForUpdate = ko.computed(() =>
this.packages().filter(item => item && '' !== item.installed && !!item.compare)
this.packages().filter(item => item && item.installed && !!item.compare)
);
this.packagesAvailableForInstallation = ko.computed(() =>
this.packages().filter(item => item && '' === item.installed)
this.packages().filter(item => item && !item.installed)
);
this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));

View file

@ -78,7 +78,7 @@ class PluginsAdminSettings {
onPluginDisableRequest(result, data) {
if (StorageResultType.Success === result && data) {
if (!data.Result && data.ErrorCode) {
if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && '' !== data.ErrorMessage) {
if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && data.ErrorMessage) {
PluginStore.plugins.error(data.ErrorMessage);
} else {
PluginStore.plugins.error(getNotification(data.ErrorCode));

View file

@ -76,9 +76,9 @@ class SecurityAdminSettings {
this.onNewAdminPasswordResponse = this.onNewAdminPasswordResponse.bind(this);
}
@command((self) => '' !== trim(self.adminLogin()) && '' !== self.adminPassword())
@command((self) => trim(self.adminLogin()) && self.adminPassword())
saveNewAdminPasswordCommand() {
if ('' === trim(this.adminLogin())) {
if (!trim(this.adminLogin())) {
this.adminLoginError(true);
return false;
}

View file

@ -61,7 +61,7 @@ class FiltersUserSettings {
@command((self) => self.haveChanges())
saveChangesCommand() {
if (!this.filters.saving()) {
if (this.filterRaw.active() && '' === trim(this.filterRaw())) {
if (this.filterRaw.active() && !trim(this.filterRaw())) {
this.filterRaw.error(true);
return false;
}

View file

@ -44,7 +44,7 @@ class FoldersUserSettings {
folderEditOnEnter(folder) {
const nameToEdit = folder ? trim(folder.nameForEdit()) : '';
if ('' !== nameToEdit && folder.name() !== nameToEdit) {
if (nameToEdit && folder.name() !== nameToEdit) {
Local.set(ClientSideKeyName.FoldersLashHash, '');
getApp().foldersPromisesActionHelper(

View file

@ -55,7 +55,7 @@ class GeneralUserSettings {
this.identityMain = ko.computed(() => {
const list = this.identities();
return isArray(list) ? list.find(item => item && '' === item.id()) : null;
return isArray(list) ? list.find(item => item && !item.id()) : null;
});
this.identityMainDesc = ko.computed(() => {

View file

@ -16,7 +16,7 @@ class TemplatesUserSettings {
this.processText = ko.computed(() =>
TemplateStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : ''
);
this.visibility = ko.computed(() => ('' === this.processText() ? 'hidden' : 'visible'));
this.visibility = ko.computed(() => this.processText() ? 'visible' : 'hidden');
this.templateForDeletion = ko.observable(null).deleteAccessHelper();
}