mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
fix(sync-status): Fix logic for checking sync status:
- Only check sync status keys that belong to actual models being synced - Return false if state object is empty
This commit is contained in:
parent
79e15e8408
commit
eb1f9409ef
|
@ -1,5 +1,5 @@
|
|||
_ = require 'underscore'
|
||||
{Actions, DatabaseStore} = require 'nylas-exports'
|
||||
{Actions, DatabaseStore, NylasSyncStatusStore} = require 'nylas-exports'
|
||||
NylasLongConnection = require './nylas-long-connection'
|
||||
ContactRankingsCache = require './contact-rankings-cache'
|
||||
|
||||
|
@ -71,7 +71,7 @@ class NylasSyncWorker
|
|||
DatabaseStore.findJSONBlob("NylasSyncWorker:#{@_account.id}").then (json) =>
|
||||
@_state = json ? {}
|
||||
@_state.longConnectionStatus = NylasLongConnection.Status.Idle
|
||||
for key in ['threads', 'labels', 'folders', 'drafts', 'contacts', 'calendars', 'events']
|
||||
for key in NylasSyncStatusStore.ModelsForSync
|
||||
@_state[key].busy = false if @_state[key]
|
||||
@resume()
|
||||
|
||||
|
|
|
@ -4,7 +4,19 @@ AccountStore = require './account-store'
|
|||
DatabaseStore = require './database-store'
|
||||
NylasStore = require 'nylas-store'
|
||||
|
||||
ModelsForSync = [
|
||||
'threads',
|
||||
'messages',
|
||||
'labels',
|
||||
'folders',
|
||||
'drafts',
|
||||
'contacts',
|
||||
'calendars',
|
||||
'events'
|
||||
]
|
||||
|
||||
class NylasSyncStatusStore extends NylasStore
|
||||
ModelsForSync: ModelsForSync
|
||||
|
||||
constructor: ->
|
||||
@_statesByAccount = {}
|
||||
|
@ -29,12 +41,13 @@ class NylasSyncStatusStore extends NylasStore
|
|||
return false unless @_statesByAccount[acctId]
|
||||
if model
|
||||
return @_statesByAccount[acctId][model]?.complete ? false
|
||||
for _model, modelState of @_statesByAccount[acctId]
|
||||
continue if _model in ['longConnectionStatus', 'nextRetryTimestamp']
|
||||
return false if not modelState.complete
|
||||
for _model in ModelsForSync
|
||||
modelState = @_statesByAccount[_model]
|
||||
return false if not modelState?.complete
|
||||
return true
|
||||
|
||||
isSyncComplete: =>
|
||||
return false if _.isEmpty(@_statesByAccount)
|
||||
for acctId of @_statesByAccount
|
||||
return false if not @isSyncCompleteForAccount(acctId)
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue