mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 08:35:16 +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()
|
@_restoreQueue()
|
||||||
|
|
||||||
|
NylasEnv.onBeforeUnload((finishUnload) =>
|
||||||
|
@_saveQueue()
|
||||||
|
.finally(finishUnload)
|
||||||
|
return false
|
||||||
|
)
|
||||||
|
|
||||||
@listenTo Actions.queueTask, @enqueue
|
@listenTo Actions.queueTask, @enqueue
|
||||||
@listenTo Actions.queueTasks, (tasks) =>
|
@listenTo Actions.queueTasks, (tasks) =>
|
||||||
return unless tasks and tasks.length > 0
|
return unless tasks and tasks.length > 0
|
||||||
|
@ -325,10 +331,14 @@ class TaskQueue
|
||||||
@_queue = queue
|
@_queue = queue
|
||||||
@_updateSoon()
|
@_updateSoon()
|
||||||
|
|
||||||
|
_saveQueue: =>
|
||||||
|
return DatabaseStore.inTransaction((t) =>
|
||||||
|
return t.persistJSONBlob(JSONBlobStorageKey, @_queue ? [])
|
||||||
|
)
|
||||||
|
|
||||||
_updateSoon: =>
|
_updateSoon: =>
|
||||||
@_updateSoonThrottled ?= _.throttle =>
|
@_updateSoonThrottled ?= _.throttle =>
|
||||||
DatabaseStore.inTransaction (t) =>
|
@_saveQueue()
|
||||||
t.persistJSONBlob(JSONBlobStorageKey, @_queue ? [])
|
|
||||||
_.defer =>
|
_.defer =>
|
||||||
@_processQueue()
|
@_processQueue()
|
||||||
@_ensurePeriodicUpdates()
|
@_ensurePeriodicUpdates()
|
||||||
|
|
Loading…
Reference in a new issue