mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 00:06:06 +08:00
fix(sync): fix sync status store
This commit is contained in:
parent
2441db6546
commit
1f5531bd08
2
src/K2
2
src/K2
|
@ -1 +1 @@
|
|||
Subproject commit 30d60c5a752906083f45060b617b6f091eff0012
|
||||
Subproject commit 672848dbdcad2c5bf4223897e6418bcb667a1bb3
|
|
@ -21,7 +21,7 @@ import CategoryStore from './category-store'
|
|||
* localSync,
|
||||
* n1Cloud,
|
||||
* },
|
||||
* folders: {
|
||||
* folderSyncProgress: {
|
||||
* inbox: 0.5,
|
||||
* archive: 0.2,
|
||||
* ...
|
||||
|
@ -86,10 +86,12 @@ class NylasSyncStatusStore extends NylasStore {
|
|||
const progress = (+fetchedmax - +fetchedmin) / uidnext
|
||||
updates[name] = progress
|
||||
} else {
|
||||
updates[name] = null
|
||||
// We don't have a uidnext if the sync hasn't started at all,
|
||||
// but we've fund the folder.
|
||||
updates[name] = "SYNC_NOT_STARTED"
|
||||
}
|
||||
}
|
||||
this._updateState(accountId, {folders: updates})
|
||||
this._updateState(accountId, {folderSyncProgress: updates})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,9 +120,9 @@ class NylasSyncStatusStore extends NylasStore {
|
|||
isCategoryListSynced(accountId) {
|
||||
const state = this._statesByAccount[accountId]
|
||||
if (!state) { return false }
|
||||
const folders = Object.keys(state.folders || {})
|
||||
if (folders.length === 0) { return false }
|
||||
return folders.some((folder) => state.folders[folder] != null)
|
||||
const folderNames = Object.keys(state.folderSyncProgress || {})
|
||||
if (folderNames.length === 0) { return false }
|
||||
return folderNames.some((name) => state.folderSyncProgress[name] !== "SYNC_NOT_STARTED")
|
||||
}
|
||||
|
||||
whenCategoryListSynced(accountId) {
|
||||
|
@ -146,12 +148,12 @@ class NylasSyncStatusStore extends NylasStore {
|
|||
}
|
||||
|
||||
if (folderName) {
|
||||
return state.folders[folderName].complete === true
|
||||
return state.folderSyncProgress[folderName] >= 1
|
||||
}
|
||||
const folderNames = Object.keys(state.folders)
|
||||
const folderNames = Object.keys(state.folderSyncProgress)
|
||||
for (const fname of folderNames) {
|
||||
const folder = state.folders[fname]
|
||||
if (folder.complete !== true) {
|
||||
const syncProgress = state.folderSyncProgress[fname]
|
||||
if (syncProgress < 1 || syncProgress === "SYNC_NOT_STARTED") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue