mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
fix: improve fetch items progress
This commit is contained in:
@@ -157,7 +157,7 @@ class Sync {
|
|||||||
|
|
||||||
async fetch(lastSynced) {
|
async fetch(lastSynced) {
|
||||||
const serverResponse = await new Promise((resolve, reject) => {
|
const serverResponse = await new Promise((resolve, reject) => {
|
||||||
let counter = { count: 0, queue: 0 };
|
let counter = { count: 0, queue: null };
|
||||||
this.connection.stream("FetchItems", lastSynced).subscribe({
|
this.connection.stream("FetchItems", lastSynced).subscribe({
|
||||||
next: (/** @type {SyncTransferItem} */ syncStatus) => {
|
next: (/** @type {SyncTransferItem} */ syncStatus) => {
|
||||||
const { total, item, synced, lastSynced } = syncStatus;
|
const { total, item, synced, lastSynced } = syncStatus;
|
||||||
@@ -166,17 +166,15 @@ class Sync {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
if (counter.queue === null) counter.queue = total;
|
||||||
|
|
||||||
++counter.count;
|
|
||||||
++counter.queue;
|
|
||||||
const progress = counter.count;
|
|
||||||
this.onSyncItem(syncStatus)
|
this.onSyncItem(syncStatus)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
sendSyncProgressEvent(
|
sendSyncProgressEvent(
|
||||||
this.db.eventManager,
|
this.db.eventManager,
|
||||||
`download`,
|
`download`,
|
||||||
total,
|
total,
|
||||||
progress
|
++counter.count
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(reject)
|
.catch(reject)
|
||||||
|
|||||||
Reference in New Issue
Block a user