diff --git a/dev/Knoin/AbstractModel.js b/dev/Knoin/AbstractModel.js index 9b4b48e5d..4da7ebcc3 100644 --- a/dev/Knoin/AbstractModel.js +++ b/dev/Knoin/AbstractModel.js @@ -8,7 +8,7 @@ function dispose(disposable) { function typeCast(curValue, newValue) { switch (typeof curValue) { - case 'boolean': return !!newValue; + case 'boolean': return 0 != newValue && !!newValue; case 'number': return isFinite(newValue) ? parseFloat(newValue) : 0; case 'string': return null != newValue ? '' + newValue : ''; case 'object': diff --git a/dev/Model/Filter.js b/dev/Model/Filter.js index 35855bcae..91d99f8fb 100644 --- a/dev/Model/Filter.js +++ b/dev/Model/Filter.js @@ -188,7 +188,7 @@ export class FilterModel extends AbstractModel { return { // '@Object': 'Object/Filter', ID: this.id, - Enabled: this.enabled() ? '1' : '0', + Enabled: this.enabled() ? 1 : 0, Name: this.name(), Conditions: this.conditions.map(item => item.toJson()), ConditionsType: this.conditionsType(), @@ -199,9 +199,9 @@ export class FilterModel extends AbstractModel { ActionValueThird: this.actionValueThird(), ActionValueFourth: this.actionValueFourth(), - Keep: this.actionKeep() ? '1' : '0', - Stop: this.actionNoStop() ? '0' : '1', - MarkAsRead: this.actionMarkAsRead() ? '1' : '0' + Keep: this.actionKeep() ? 1 : 0, + Stop: this.actionNoStop() ? 0 : 1, + MarkAsRead: this.actionMarkAsRead() ? 1 : 0 }; } @@ -236,9 +236,9 @@ export class FilterModel extends AbstractModel { ); } - filter.actionNoStop(!json.Stop); - filter.actionKeep(!!json.Keep); - filter.actionMarkAsRead(!!json.MarkAsRead); + filter.actionKeep(1 == json.Keep); + filter.actionNoStop(0 == json.Stop); + filter.actionMarkAsRead(1 == json.MarkAsRead); } return filter; }