mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-12 07:34:52 +08:00
fix(db): Allow string attributes to be null. Never coerce to ""
- Fixes a bug where reply_to_message_id = "" when we receive drafts from the sever. - In general behavior should be consistent with API. Since they allow null we should too.
This commit is contained in:
parent
ddb91b7e75
commit
57e7df8356
3 changed files with 13 additions and 9 deletions
|
@ -79,8 +79,8 @@ describe "Event", ->
|
|||
it "accepts a JSON response", ->
|
||||
e1 = (new Event).fromJSON(json_event)
|
||||
expect(e1.title).toBe "Meeting with Ben Bitdiddle"
|
||||
expect(e1.description).toBe ''
|
||||
expect(e1.location).toBe ''
|
||||
expect(e1.description).toBe null
|
||||
expect(e1.location).toBe null
|
||||
expect(e1.start).toBe 1408120200
|
||||
expect(e1.end).toBe 1408123800
|
||||
expect(e1.participants[0].name).toBe "Ben Bitdiddle"
|
||||
|
|
|
@ -11,7 +11,10 @@ Section: Database
|
|||
###
|
||||
class AttributeString extends Attribute
|
||||
toJSON: (val) -> val
|
||||
fromJSON: (val) -> val || ""
|
||||
fromJSON: (val) ->
|
||||
return null if val is null or val is undefined or val is false
|
||||
return val + ""
|
||||
|
||||
|
||||
# Public: Returns a {Matcher} for objects starting with the provided value.
|
||||
startsWith: (val) -> new Matcher(@, 'startsWith', val)
|
||||
|
|
|
@ -90,12 +90,13 @@ class SyncbackDraftTask extends Task
|
|||
if draft.accountId is account.id
|
||||
return Promise.resolve(draft)
|
||||
else
|
||||
NylasAPI.makeRequest
|
||||
path: "/drafts/#{draft.serverId}"
|
||||
accountId: draft.accountId
|
||||
method: "DELETE"
|
||||
body: {version: draft.version}
|
||||
returnsModel: false
|
||||
if draft.serverId
|
||||
NylasAPI.makeRequest
|
||||
path: "/drafts/#{draft.serverId}"
|
||||
accountId: draft.accountId
|
||||
method: "DELETE"
|
||||
body: {version: draft.version}
|
||||
returnsModel: false
|
||||
|
||||
draft.accountId = account.id
|
||||
delete draft.serverId
|
||||
|
|
Loading…
Add table
Reference in a new issue