Better Sieve rainloop.user script handling

This commit is contained in:
the-djmaze 2023-01-25 09:28:09 +01:00
parent f080a302b1
commit 4cfd6479ce
51 changed files with 92 additions and 99 deletions

View file

@ -82,11 +82,9 @@ export class AbstractModel {
}
revivePropertiesFromJson(json) {
let model = this.constructor;
if (!model.validJson(json)) {
return false;
}
forEachObjectEntry(json, (key, value) => {
const model = this.constructor,
valid = model.validJson(json);
valid && forEachObjectEntry(json, (key, value) => {
if ('@' !== key[0]) try {
key = key[0].toLowerCase() + key.slice(1);
switch (typeof this[key])
@ -104,9 +102,12 @@ export class AbstractModel {
case 'string':
this[key] = typeCast(this[key], value);
break;
// fall through
case 'undefined':
default:
console.log(`Undefined ${model.name}.${key} not set`);
// this[key] = value;
break;
// default:
// console.log((typeof this[key])+` ${model.name}.${key} not revived`);
// console.log((typeof this[key])+' '+(model.name)+'.'+key+' not revived');
}
} catch (e) {
@ -114,7 +115,7 @@ export class AbstractModel {
console.error(e);
}
});
return true;
return valid;
}
}