mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 16:14:01 +08:00
fix(sync-status) When getting sync status, make sure account and progress data exists
Summary: See title Test Plan: manual Reviewers: evan, halla Reviewed By: evan, halla Differential Revision: https://phab.nylas.com/D3588
This commit is contained in:
parent
f9d4974b51
commit
af677e3b43
1 changed files with 8 additions and 3 deletions
|
@ -118,11 +118,14 @@ class NylasSyncStatusStore extends NylasStore {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the weighted sync progress for all accounts as a percentage, and
|
||||
* Returns the weighted sync progress as a percentage, and
|
||||
* the total number of messages to sync for a given account
|
||||
*/
|
||||
getSyncProgressForAccount(accountId) {
|
||||
const {folderSyncProgress = {}} = this._statesByAccount[accountId]
|
||||
const state = this._statesByAccount[accountId]
|
||||
if (!state) { return null }
|
||||
const {folderSyncProgress} = this._statesByAccount[accountId]
|
||||
if (!folderSyncProgress) { return null }
|
||||
const folderNames = Object.keys(folderSyncProgress)
|
||||
const progressPerFolder = folderNames.map(fname => folderSyncProgress[fname])
|
||||
const weightedProgress = progressPerFolder.reduce(
|
||||
|
@ -144,7 +147,9 @@ class NylasSyncStatusStore extends NylasStore {
|
|||
getSyncProgress() {
|
||||
const accountIds = AccountStore.accountIds()
|
||||
const progressPerAccount = (
|
||||
accountIds.map(accId => this.getSyncProgressForAccount(accId))
|
||||
accountIds
|
||||
.map(accId => this.getSyncProgressForAccount(accId))
|
||||
.filter(p => p != null)
|
||||
)
|
||||
const weightedProgress = progressPerAccount.reduce(
|
||||
(accum, {progress, total}) => accum + progress * total, 0
|
||||
|
|
Loading…
Reference in a new issue