mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-07 08:37:49 +08:00
fix(close): Closing a draft always works on the first try
We were accidentally firing atom.close() in the same tick that we returned false and canceled the close.
This commit is contained in:
parent
cb8427f447
commit
728135e07d
1 changed files with 5 additions and 3 deletions
|
@ -159,13 +159,15 @@ class DraftStore
|
|||
if session.draft()?.pristine
|
||||
Actions.queueTask(new DestroyDraftTask(session.draftLocalId))
|
||||
else
|
||||
promise = session.changes.commit()
|
||||
promises.push(promise) unless promise.isFulfilled()
|
||||
promises.push(session.changes.commit())
|
||||
|
||||
if promises.length > 0
|
||||
# Important: There are some scenarios where all the promises resolve instantly.
|
||||
# Firing atom.close() does nothing if called within an existing beforeUnload
|
||||
# handler, so we need to always defer by one tick before re-firing close.
|
||||
Promise.settle(promises).then =>
|
||||
@_draftSessions = {}
|
||||
atom.close()
|
||||
_.defer -> atom.close()
|
||||
|
||||
# Stop and wait before closing
|
||||
return false
|
||||
|
|
Loading…
Reference in a new issue