mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 00:25:03 +08:00
fix(task-queue): Save the task queue before closing the window
Summary: Save the final state of the TaskQueue to the database before window gets unloaded Test Plan: Manual Reviewers: evan, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D3408
This commit is contained in:
parent
5b1ee293dc
commit
7ac7fa58ec
1 changed files with 12 additions and 2 deletions
|
@ -73,6 +73,12 @@ class TaskQueue
|
|||
|
||||
@_restoreQueue()
|
||||
|
||||
NylasEnv.onBeforeUnload((finishUnload) =>
|
||||
@_saveQueue()
|
||||
.finally(finishUnload)
|
||||
return false
|
||||
)
|
||||
|
||||
@listenTo Actions.queueTask, @enqueue
|
||||
@listenTo Actions.queueTasks, (tasks) =>
|
||||
return unless tasks and tasks.length > 0
|
||||
|
@ -325,10 +331,14 @@ class TaskQueue
|
|||
@_queue = queue
|
||||
@_updateSoon()
|
||||
|
||||
_saveQueue: =>
|
||||
return DatabaseStore.inTransaction((t) =>
|
||||
return t.persistJSONBlob(JSONBlobStorageKey, @_queue ? [])
|
||||
)
|
||||
|
||||
_updateSoon: =>
|
||||
@_updateSoonThrottled ?= _.throttle =>
|
||||
DatabaseStore.inTransaction (t) =>
|
||||
t.persistJSONBlob(JSONBlobStorageKey, @_queue ? [])
|
||||
@_saveQueue()
|
||||
_.defer =>
|
||||
@_processQueue()
|
||||
@_ensurePeriodicUpdates()
|
||||
|
|
Loading…
Reference in a new issue