mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 07:46:06 +08:00
Look at “busy” flag to see whether mailsync is still indexing message bodies
This commit is contained in:
parent
ebaa718b21
commit
556b633663
|
@ -25,12 +25,17 @@ export default class InitialSyncActivity extends React.Component {
|
|||
this.setState({syncState: FolderSyncProgressStore.getSyncState()});
|
||||
}
|
||||
|
||||
renderFolderProgress(folderPath, progress) {
|
||||
let status = 'busy';
|
||||
let progressLabel = `In Progress (${Math.round(progress * 100)}%)`;
|
||||
if (progress === 1) {
|
||||
status = 'complete';
|
||||
progressLabel = '';
|
||||
renderFolderProgress(folderPath, {progress, busy}) {
|
||||
let status = 'complete';
|
||||
let progressLabel = '';
|
||||
|
||||
if (busy) {
|
||||
status = 'busy';
|
||||
if (progress < 1) {
|
||||
progressLabel = `Scanning folder (${Math.round(progress * 100)}%)`;
|
||||
} else {
|
||||
progressLabel = `Indexing messages...`;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -53,8 +58,8 @@ export default class InitialSyncActivity extends React.Component {
|
|||
return false;
|
||||
}
|
||||
|
||||
let folderStates = Object.entries(accountSyncState).map(([folderPath, {progress}]) => {
|
||||
return this.renderFolderProgress(folderPath, progress)
|
||||
let folderStates = Object.entries(accountSyncState).map(([folderPath, folderState]) => {
|
||||
return this.renderFolderProgress(folderPath, folderState)
|
||||
})
|
||||
|
||||
if (folderStates.length === 0) {
|
||||
|
|
|
@ -7,10 +7,8 @@ const TEST_NYLAS_ID = "icihsnqh4pwujyqihlrj70vh"
|
|||
describe("IdentityStore", function identityStoreSpec() {
|
||||
beforeEach(() => {
|
||||
this.identityJSON = {
|
||||
valid_until: 1500093224,
|
||||
firstname: "Nylas 050",
|
||||
lastname: "Test",
|
||||
free_until: 1500006814,
|
||||
firstName: "Nylas 050",
|
||||
lastName: "Test",
|
||||
email: "nylas050test@evanmorikawa.com",
|
||||
id: TEST_NYLAS_ID,
|
||||
featureUsage: {
|
||||
|
|
|
@ -42,9 +42,15 @@ class FolderSyncProgressStore extends NylasStore {
|
|||
const folders = CategoryStore.categories(accountId).filter(cat => cat instanceof Folder)
|
||||
const state = {};
|
||||
|
||||
/*
|
||||
`localStatus` is populated by C++ mailsync. We translate it to a simpler
|
||||
representation that the JS side can rely on as the underlying
|
||||
implementation changes.
|
||||
*/
|
||||
for (const folder of folders) {
|
||||
const {uidnext, syncedMinUID} = folder.localStatus || {};
|
||||
const {uidnext, syncedMinUID, busy} = folder.localStatus || {};
|
||||
state[folder.path] = {
|
||||
busy: busy !== undefined ? busy : true,
|
||||
progress: 1.0 - (syncedMinUID - 1) / uidnext,
|
||||
total: uidnext,
|
||||
}
|
||||
|
@ -52,24 +58,25 @@ class FolderSyncProgressStore extends NylasStore {
|
|||
|
||||
this._statesByAccount[accountId] = state;
|
||||
}
|
||||
this._triggerDebounced()
|
||||
this._triggerDebounced();
|
||||
}
|
||||
|
||||
getSyncState() {
|
||||
return this._statesByAccount
|
||||
return this._statesByAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if N1's local cache contains the entire list of available
|
||||
* Returns true if Merani's local cache contains the entire list of available
|
||||
* folders and labels.
|
||||
*
|
||||
* This will be true if any of the available folders have started syncing,
|
||||
* given that K2 wont commence folder sync until it has fetched the whole list
|
||||
* of folders and labels
|
||||
* since mailsync doesn't start folder sync until it has fetched the whole list
|
||||
* of folders and labels.
|
||||
*/
|
||||
isCategoryListSynced(accountId) {
|
||||
const state = this._statesByAccount[accountId];
|
||||
if (!state) { return false }
|
||||
return Object.values(state).some((i) => i.progress > 0)
|
||||
return Object.values(state).some((i) => i.progress > 0);
|
||||
}
|
||||
|
||||
whenCategoryListSynced(accountId) {
|
||||
|
@ -94,16 +101,18 @@ class FolderSyncProgressStore extends NylasStore {
|
|||
}
|
||||
|
||||
if (folderPath) {
|
||||
return state[folderPath].progress >= 1
|
||||
return !state[folderPath].busy && state[folderPath].progress >= 1
|
||||
}
|
||||
|
||||
const folderPaths = Object.keys(state)
|
||||
for (const fname of folderPaths) {
|
||||
const syncProgress = state[fname].progress
|
||||
if (syncProgress < 1) {
|
||||
return false
|
||||
for (const aFolderPath of folderPaths) {
|
||||
const {progress, busy} = state[aFolderPath];
|
||||
if (busy || progress < 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
isSyncComplete() {
|
||||
|
|
Loading…
Reference in a new issue