make a shared olm util for the whole session

This commit is contained in:
Bruno Windels 2020-09-01 17:57:59 +02:00
parent 9870483121
commit 81a1573e3b
2 changed files with 4 additions and 3 deletions

View file

@ -35,10 +35,11 @@ export class Session {
this._user = new User(sessionInfo.userId); this._user = new User(sessionInfo.userId);
this._olm = olm; this._olm = olm;
this._e2eeAccount = null; this._e2eeAccount = null;
const olmUtil = olm ? new olm.Utility() : null;
this._deviceTracker = olm ? new DeviceTracker({ this._deviceTracker = olm ? new DeviceTracker({
storage, storage,
getSyncToken: () => this.syncToken, getSyncToken: () => this.syncToken,
olm, olmUtil,
}) : null; }) : null;
} }

View file

@ -36,11 +36,11 @@ function deviceKeysAsDeviceIdentity(deviceSection) {
} }
export class DeviceTracker { export class DeviceTracker {
constructor({storage, getSyncToken, olm}) { constructor({storage, getSyncToken, olmUtil}) {
this._storage = storage; this._storage = storage;
this._getSyncToken = getSyncToken; this._getSyncToken = getSyncToken;
this._identityChangedForRoom = null; this._identityChangedForRoom = null;
this._olmUtil = new olm.Utility(); this._olmUtil = olmUtil;
} }
async writeDeviceChanges(deviceLists, txn) { async writeDeviceChanges(deviceLists, txn) {