mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 15:15:12 +08:00
feat(sync): Resume sync worker action from sidebar
This commit is contained in:
parent
07583d6f11
commit
157c048ca0
4 changed files with 31 additions and 6 deletions
|
@ -105,7 +105,7 @@ class ActivitySidebar extends React.Component
|
|||
</div>
|
||||
|
||||
_onTryAgain: =>
|
||||
# TODO
|
||||
Actions.retryInitialSync()
|
||||
|
||||
_onDataChanged: =>
|
||||
@setState(@_getStateFromStores())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
_ = require 'underscore'
|
||||
{DatabaseStore} = require 'nylas-exports'
|
||||
{Actions, DatabaseStore} = require 'nylas-exports'
|
||||
NylasLongConnection = require './nylas-long-connection'
|
||||
|
||||
PAGE_SIZE = 250
|
||||
|
@ -45,6 +45,8 @@ class NylasSyncWorker
|
|||
# indirection needed so resumeFetches can be spied on
|
||||
@resumeFetches()
|
||||
|
||||
@_unlisten = Actions.retryInitialSync.listen(@_onRetryInitialSync, @)
|
||||
|
||||
@_state = null
|
||||
DatabaseStore.findJSONObject("NylasSyncWorker:#{@_account.id}").then (json) =>
|
||||
@_state = json ? {}
|
||||
|
@ -76,6 +78,7 @@ class NylasSyncWorker
|
|||
@resumeFetches()
|
||||
|
||||
cleanup: ->
|
||||
@_unlisten?()
|
||||
@_resumeTimer.cancel()
|
||||
@_connection.end()
|
||||
@_terminated = true
|
||||
|
@ -160,4 +163,7 @@ class NylasSyncWorker
|
|||
,100
|
||||
@_writeState()
|
||||
|
||||
_onRetryInitialSync: =>
|
||||
@resumeFetches()
|
||||
|
||||
NylasSyncWorker.BackoffTimer = BackoffTimer
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
_ = require 'underscore'
|
||||
{DatabaseStore, Account, Thread} = require 'nylas-exports'
|
||||
{Actions, DatabaseStore, Account, Thread} = require 'nylas-exports'
|
||||
NylasLongConnection = require '../lib/nylas-long-connection'
|
||||
NylasSyncWorker = require '../lib/nylas-sync-worker'
|
||||
|
||||
|
@ -221,6 +221,18 @@ describe "NylasSyncWorker", ->
|
|||
@request.requestOptions.error(new Error("Oh no a network error"))
|
||||
expect(@apiRequests.length).toBe(0)
|
||||
|
||||
it "resumes when a action forces it to", ->
|
||||
err = new Error("Oh no a network error")
|
||||
@request.requestOptions.error(err)
|
||||
expect(@worker.state().threads.busy).toEqual(false)
|
||||
expect(@worker.state().threads.complete).toEqual(false)
|
||||
spyOn(@worker, 'resumeFetches').andCallThrough()
|
||||
Actions.retryInitialSync()
|
||||
expect(@worker.resumeFetches).toHaveBeenCalled()
|
||||
expect(@worker.resumeFetches.calls.length).toBe 1
|
||||
expect(@worker.state().threads.busy).toEqual(true)
|
||||
expect(@worker.state().threads.error).toBe(null)
|
||||
|
||||
describe "cleanup", ->
|
||||
it "should termiate the long polling connection", ->
|
||||
spyOn(@connection, 'end')
|
||||
|
|
|
@ -94,7 +94,7 @@ class Actions
|
|||
###
|
||||
Public: Queue a {Task} object to the {TaskQueue}.
|
||||
|
||||
*Scope: Main Window*
|
||||
*Scope: Work Window*
|
||||
###
|
||||
@queueTask: ActionScopeWorkWindow
|
||||
|
||||
|
@ -103,7 +103,7 @@ class Actions
|
|||
###
|
||||
Public: Dequeue all {Task}s from the {TaskQueue}. Use with care.
|
||||
|
||||
*Scope: Main Window*
|
||||
*Scope: Work Window*
|
||||
###
|
||||
@dequeueAllTasks: ActionScopeWorkWindow
|
||||
@dequeueTask: ActionScopeWorkWindow
|
||||
|
@ -111,7 +111,7 @@ class Actions
|
|||
###
|
||||
Public: Dequeue a {Task} matching the description provided.
|
||||
|
||||
*Scope: Main Window*
|
||||
*Scope: Work Window*
|
||||
###
|
||||
@dequeueMatchingTask: ActionScopeWorkWindow
|
||||
|
||||
|
@ -123,6 +123,13 @@ class Actions
|
|||
@didMakeAPIRequest: ActionScopeWorkWindow
|
||||
@sendFeedback: ActionScopeWorkWindow
|
||||
|
||||
###
|
||||
Public: Retry the initial sync
|
||||
|
||||
*Scope: Work Window*
|
||||
###
|
||||
@retryInitialSync: ActionScopeWorkWindow
|
||||
|
||||
|
||||
###
|
||||
Public: Show the developer console for the current window.
|
||||
|
|
Loading…
Reference in a new issue