mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
fix(db): Atomically was not resolving with a value, fixes mail notifications
This commit is contained in:
parent
a35416ae94
commit
42f65798d6
|
@ -462,15 +462,17 @@ class DatabaseStore extends NylasStore
|
|||
|
||||
atomically: (fn) =>
|
||||
@_atomicPromise ?= Promise.resolve()
|
||||
@_atomicPromise = @_atomicPromise.finally =>
|
||||
@_atomicPromise = @_atomicPromise.then =>
|
||||
@_atomically(fn)
|
||||
return @_atomicPromise
|
||||
|
||||
_atomically: (fn) ->
|
||||
@_query("BEGIN EXCLUSIVE TRANSACTION")
|
||||
.then => fn()
|
||||
.then => @_query("COMMIT")
|
||||
.then => Promise.resolve()
|
||||
.then =>
|
||||
fn()
|
||||
.then (val) =>
|
||||
@_query("COMMIT").then =>
|
||||
Promise.resolve(val)
|
||||
|
||||
########################################################################
|
||||
########################### PRIVATE METHODS ############################
|
||||
|
|
Loading…
Reference in a new issue