mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 16:26:08 +08:00
fix(sync-status): Use sync progress from K2
Summary: Sister diff to D3817 syncState on folders may contain arbitrarily long arrays of UIDs (particularly, failedUIDs). If we serialize this JSON column to edgehill.db, we can end up serializing very large objects when persisting the local task queue. When the queue contains many tasks, this can balloon the JSON blob to megabytes, causing the main window and the worker window to become unresponsive. The UI doesn't need to know about IMAP bookkeeping internals, so serialize the sync progress instead of the sync state. This has the advantages that (1) we don't need to worry about future keys added to the syncState being large and (2) when we add Exchange support we already have an abstraction for sync progress. Test Plan: manual Reviewers: juan, mark, halla Reviewed By: halla Differential Revision: https://phab.nylas.com/D3819
This commit is contained in:
parent
e4ce1f8e1e
commit
bf8818d208
2
src/K2
2
src/K2
|
@ -1 +1 @@
|
|||
Subproject commit c993ec3b8749e73d4eb1ab8f457debfa21a05858
|
||||
Subproject commit 5b659382d61f2774040be1e310f380bd7e0bea78
|
|
@ -71,9 +71,9 @@ export default class Category extends Model {
|
|||
modelKey: 'displayName',
|
||||
jsonKey: 'display_name',
|
||||
}),
|
||||
syncState: Attributes.Object({
|
||||
modelKey: 'syncState',
|
||||
jsonKey: 'sync_state',
|
||||
syncProgress: Attributes.Object({
|
||||
modelKey: 'syncProgress',
|
||||
jsonKey: 'sync_progress',
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
@ -88,21 +88,12 @@ class NylasSyncStatusStore extends NylasStore {
|
|||
const updates = {}
|
||||
for (const folder of folders) {
|
||||
const name = folder.name || folder.displayName
|
||||
const {uidnext, fetchedmin, fetchedmax, minUID, oldestProcessedDate} = folder.syncState || {}
|
||||
if (uidnext) {
|
||||
// TODO: when we unify the databases, we shouldn't need code to
|
||||
// calculate this in two different places anymore
|
||||
const progress = (+fetchedmax - +fetchedmin + 1) / (uidnext - minUID + 1)
|
||||
const {approxPercentComplete, approxTotal, oldestProcessedDate} = folder.syncProgress || {};
|
||||
updates[name] = {
|
||||
progress,
|
||||
total: uidnext,
|
||||
progress: approxPercentComplete || 0,
|
||||
total: approxTotal || 0,
|
||||
oldestProcessedDate: oldestProcessedDate ? new Date(oldestProcessedDate) : new Date(),
|
||||
}
|
||||
} else {
|
||||
// We don't have a uidnext if the sync hasn't started at all,
|
||||
// but we've found the folder.
|
||||
updates[name] = {progress: 0, total: 0, oldestProcessedDate: new Date()}
|
||||
}
|
||||
}
|
||||
this._updateState(accountId, {folderSyncProgress: updates})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue