core: turn off sync push by default

This commit is contained in:
Abdullah Atta
2024-01-31 11:58:25 +05:00
parent aa2a8ab6f4
commit 9a0c129844

View File

@@ -293,39 +293,41 @@ class Sync {
} }
async send(oldLastSynced, isForceSync, newLastSynced) { async send(oldLastSynced, isForceSync, newLastSynced) {
await this.uploadAttachments(); return false;
let isSyncInitialized = false; // await this.uploadAttachments();
let done = 0;
for await (const item of this.collector.collect(
100,
oldLastSynced,
isForceSync
)) {
if (!isSyncInitialized) {
const vaultKey = await this.db.vault._getKey();
newLastSynced = await this.connection.invoke("InitializePush", {
vaultKey,
lastSynced: newLastSynced
});
isSyncInitialized = true;
}
const result = await this.pushItem(item, newLastSynced); // let isSyncInitialized = false;
if (result) { // let done = 0;
done += item.items.length; // for await (const item of this.collector.collect(
sendSyncProgressEvent(this.db.eventManager, "upload", done); // 100,
// oldLastSynced,
// isForceSync
// )) {
// if (!isSyncInitialized) {
// const vaultKey = await this.db.vault._getKey();
// newLastSynced = await this.connection.invoke("InitializePush", {
// vaultKey,
// lastSynced: newLastSynced
// });
// isSyncInitialized = true;
// }
this.logger.info(`Batch sent (${done})`); // const result = await this.pushItem(item, newLastSynced);
} else { // if (result) {
this.logger.error( // done += item.items.length;
new Error(`Failed to send batch. Server returned falsy response.`) // sendSyncProgressEvent(this.db.eventManager, "upload", done);
);
} // this.logger.info(`Batch sent (${done})`);
} // } else {
if (!isSyncInitialized) return; // this.logger.error(
await this.connection.invoke("SyncCompleted", newLastSynced); // new Error(`Failed to send batch. Server returned falsy response.`)
return true; // );
// }
// }
// if (!isSyncInitialized) return;
// await this.connection.invoke("SyncCompleted", newLastSynced);
// return true;
} }
async stop(lastSynced) { async stop(lastSynced) {