1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Add glue code to hook up the sync accumulator

The user of the SDK is responsible for DIing the main components:

  let store = new IndexedDBStore(
    new IndexedDBStoreBackend(window.indexedDB),
    new SyncAccumulator(),
  });
  await store.startup();
  let client = matrix.createClient({store: store});
This commit is contained in:
Kegan Dougal
2017-02-09 12:49:10 +00:00
parent ef57b88343
commit 3a39fd23c4
5 changed files with 92 additions and 48 deletions

View File

@@ -38,6 +38,7 @@ const Filter = require("./filter");
const SyncApi = require("./sync");
const MatrixBaseApis = require("./base-apis");
const MatrixError = httpApi.MatrixError;
const IndexedDBStore = require("./store/indexeddb").IndexedDBStore;
const SCROLLBACK_DELAY_MS = 3000;
let CRYPTO_ENABLED = false;
@@ -163,6 +164,11 @@ function MatrixClient(opts) {
this.olmVersion = Crypto.getOlmVersion();
}
// Set up a sync accumulator if we can persist room data
if (this.store instanceof IndexedDBStore) {
this._syncAccumulator = this.store.getSyncAccumulator();
}
}
utils.inherits(MatrixClient, EventEmitter);
utils.extend(MatrixClient.prototype, MatrixBaseApis.prototype);
@@ -2695,6 +2701,7 @@ MatrixClient.prototype.startClient = function(opts) {
opts = Object.assign({}, opts);
opts.crypto = this._crypto;
opts.syncAccumulator = this._syncAccumulator;
this._clientOpts = opts;
this._syncApi = new SyncApi(this, opts);