mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Bugfix: TypeError curValue is null
This commit is contained in:
parent
d71b36f09e
commit
b65b77f518
1 changed files with 42 additions and 42 deletions
|
|
@ -7,6 +7,7 @@ function dispose(disposable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function typeCast(curValue, newValue) {
|
function typeCast(curValue, newValue) {
|
||||||
|
if (null != curValue) {
|
||||||
switch (typeof curValue)
|
switch (typeof curValue)
|
||||||
{
|
{
|
||||||
case 'boolean': return 0 != newValue && !!newValue;
|
case 'boolean': return 0 != newValue && !!newValue;
|
||||||
|
|
@ -19,6 +20,7 @@ function typeCast(curValue, newValue) {
|
||||||
if (isArray(curValue) && !isArray(newValue))
|
if (isArray(curValue) && !isArray(newValue))
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,12 +86,11 @@ export class AbstractModel {
|
||||||
|
|
||||||
revivePropertiesFromJson(json) {
|
revivePropertiesFromJson(json) {
|
||||||
let model = this.constructor;
|
let model = this.constructor;
|
||||||
try {
|
|
||||||
if (!model.validJson(json)) {
|
if (!model.validJson(json)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Object.entries(json).forEach(([key, value]) => {
|
Object.entries(json).forEach(([key, value]) => {
|
||||||
if ('@' !== key[0]) {
|
if ('@' !== key[0]) try {
|
||||||
key = key[0].toLowerCase() + key.substr(1);
|
key = key[0].toLowerCase() + key.substr(1);
|
||||||
switch (typeof this[key])
|
switch (typeof this[key])
|
||||||
{
|
{
|
||||||
|
|
@ -111,12 +112,11 @@ export class AbstractModel {
|
||||||
default:
|
default:
|
||||||
// console.log((typeof this[key])+' '+(model.name)+'.'+key+' not revived');
|
// console.log((typeof this[key])+' '+(model.name)+'.'+key+' not revived');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(model.name);
|
console.log(model.name + '.' + key);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue