mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
merge all Model JSON @Object parsers into a reviveFromJson()
This commit is contained in:
parent
76648f04ae
commit
15e07a73e9
18 changed files with 378 additions and 411 deletions
|
|
@ -22,20 +22,19 @@ class TemplateModel extends AbstractModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
* @static
|
||||
* @param {FetchJsonTemplate} json
|
||||
* @returns {?TemplateModel}
|
||||
*/
|
||||
parse(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Template' === json['@Object']) {
|
||||
this.id = pString(json.ID);
|
||||
this.name = pString(json.Name);
|
||||
this.body = pString(json.Body);
|
||||
this.populated = !!json.Populated;
|
||||
|
||||
result = true;
|
||||
static reviveFromJson(json) {
|
||||
const template = super.reviveFromJson(json);
|
||||
if (template) {
|
||||
template.id = pString(json.ID);
|
||||
template.name = pString(json.Name);
|
||||
template.body = pString(json.Body);
|
||||
template.populated = !!json.Populated;
|
||||
}
|
||||
|
||||
return result;
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue