1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Add ability to do indexeddb sync work in webworker

This commit is contained in:
David Baker
2017-04-06 11:09:11 +01:00
parent b392656d60
commit f5f05a9a91
6 changed files with 342 additions and 52 deletions

View File

@@ -573,7 +573,7 @@ SyncApi.prototype._sync = function(syncOptions) {
);
return this._currentSyncRequest;
}
}).done(function(data) {
}).then(function(data) {
//debuglog('Completed sync, next_batch=' + data.next_batch);
// set the sync token NOW *before* processing the events. We do this so
@@ -584,6 +584,19 @@ SyncApi.prototype._sync = function(syncOptions) {
// Reset after a successful sync
self._failedSyncCount = 0;
// We need to wait until the sync data has been sent to the backend
// because it appears that the sync data gets modified somewhere in
// processing it in such a way as to make it no longer cloneable.
// XXX: Find out what is modifying it!
if (!isCachedResponse) {
// Don't give the store back its own cached data
return client.store.setSyncData(data).then(() => {
return data;
});
} else {
return q(data);
}
}).done((data) => {
try {
self._processSyncResponse(syncToken, data);
} catch (e) {
@@ -592,11 +605,6 @@ SyncApi.prototype._sync = function(syncOptions) {
console.error("Caught /sync error", e.stack || e);
}
// Don't give the store back its own cached data
if (!isCachedResponse) {
client.store.setSyncData(data);
}
// emit synced events
const syncEventData = {
oldSyncToken: syncToken,