sync status widget WIP

This commit is contained in:
zadam
2021-03-21 00:01:28 +01:00
parent 9dd95b62a9
commit 1a9919a866
5 changed files with 72 additions and 20 deletions

View File

@@ -46,6 +46,8 @@ async function sync() {
}
while (continueSync);
ws.syncFinished();
return {
success: true
};
@@ -59,6 +61,8 @@ async function sync() {
e.message.includes('ERR_CONNECTION_REFUSED') ||
e.message.includes('Bad Gateway'))) {
ws.syncFailed();
log.info("No connection to sync server.");
return {
@@ -69,6 +73,8 @@ async function sync() {
else {
log.info("sync failed: " + e.message + "\nstack: " + e.stack);
ws.syncFailed();
return {
success: false,
message: e.message
@@ -143,7 +149,7 @@ async function pullChanges(syncContext) {
sql.transactional(() => {
for (const {entityChange, entity} of entityChanges) {
if (!sourceIdService.isLocalSourceId(entityChange.sourceId)) {
if (!atLeastOnePullApplied && entityChange.entity !== 'recent_notes') { // send only for first
if (!atLeastOnePullApplied) { // send only for first
ws.syncPullInProgress();
atLeastOnePullApplied = true;
@@ -163,10 +169,6 @@ async function pullChanges(syncContext) {
log.info(`Pulled ${entityChanges.length} changes in ${sizeInKb} KB, starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`);
}
if (atLeastOnePullApplied) {
ws.syncPullFinished();
}
log.info("Finished pull");
}
@@ -212,6 +214,8 @@ async function pushChanges(syncContext) {
entities: entityChangesRecords
});
ws.syncPushInProgress();
log.info(`Pushing ${entityChangesRecords.length} sync changes in ` + (Date.now() - startDate.getTime()) + "ms");
lastSyncedPush = entityChangesRecords[entityChangesRecords.length - 1].entityChange.id;