mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-13 11:38:31 +08:00
fix(model): Optimization incompatible with specs, todo
This commit is contained in:
parent
4dfffae083
commit
29b077dbca
1 changed files with 3 additions and 6 deletions
|
@ -68,8 +68,7 @@ class Model
|
|||
else
|
||||
values["serverId"] ?= values["id"]
|
||||
|
||||
@constructor.attributesKeys ?= Object.keys(@constructor.attributes)
|
||||
for key in @constructor.attributesKeys
|
||||
for key in Object.keys(@constructor.attributes)
|
||||
continue if key is 'id'
|
||||
continue unless values[key]?
|
||||
@[key] = values[key]
|
||||
|
@ -104,8 +103,7 @@ class Model
|
|||
#
|
||||
if json["id"] and not Utils.isTempId(json["id"])
|
||||
@serverId = json["id"]
|
||||
@constructor.attributesKeys ?= Object.keys(@constructor.attributes)
|
||||
for key in @constructor.attributesKeys
|
||||
for key in Object.keys(@constructor.attributes)
|
||||
continue if key is 'id'
|
||||
attr = @constructor.attributes[key]
|
||||
@[key] = attr.fromJSON(json[attr.jsonKey]) unless json[attr.jsonKey] is undefined
|
||||
|
@ -121,8 +119,7 @@ class Model
|
|||
#
|
||||
toJSON: (options = {}) ->
|
||||
json = {}
|
||||
@constructor.attributesKeys ?= Object.keys(@constructor.attributes)
|
||||
for key in @constructor.attributesKeys
|
||||
for key in Object.keys(@constructor.attributes)
|
||||
continue if key is 'id'
|
||||
attr = @constructor.attributes[key]
|
||||
continue if attr instanceof Attributes.AttributeJoinedData and options.joined is false
|
||||
|
|
Loading…
Reference in a new issue