1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00
This commit is contained in:
David Baker
2018-01-12 14:17:10 +00:00
parent 60052f59a0
commit 2cdb010cff
4 changed files with 17 additions and 7 deletions

View File

@@ -100,7 +100,8 @@ export default class DeviceList {
'readonly', [IndexedDBCryptoStore.STORE_DEVICE_DATA], (txn) => { 'readonly', [IndexedDBCryptoStore.STORE_DEVICE_DATA], (txn) => {
this._cryptoStore.getEndToEndDeviceData(txn, (deviceData) => { this._cryptoStore.getEndToEndDeviceData(txn, (deviceData) => {
this._devices = deviceData ? deviceData.devices : {}, this._devices = deviceData ? deviceData.devices : {},
this._deviceTrackingStatus = deviceData ? deviceData.trackingStatus : {}; this._deviceTrackingStatus = deviceData ?
deviceData.trackingStatus : {};
this._syncToken = deviceData ? deviceData.syncToken : null; this._syncToken = deviceData ? deviceData.syncToken : null;
}); });
}, },
@@ -327,6 +328,9 @@ export default class DeviceList {
/** /**
* Replaces the list of devices for a user with the given device list * Replaces the list of devices for a user with the given device list
*
* @param {string} u The user ID
* @param {Object} devs New device info for user
*/ */
storeDevicesForUser(u, devs) { storeDevicesForUser(u, devs) {
this._devices[u] = devs; this._devices[u] = devs;

View File

@@ -812,7 +812,8 @@ Crypto.prototype.decryptEvent = function(event) {
* Handle the notification from /sync or /keys/changes that device lists have * Handle the notification from /sync or /keys/changes that device lists have
* been changed. * been changed.
* *
* @param {Object} deviceLists device_lists field from /sync, or response from * @param {Object} syncData Object containing sync tokens associated with this sync
* @param {Object} syncDeviceLists device_lists field from /sync, or response from
* /keys/changes * /keys/changes
*/ */
Crypto.prototype.handleDeviceListChanges = async function(syncData, syncDeviceLists) { Crypto.prototype.handleDeviceListChanges = async function(syncData, syncDeviceLists) {

View File

@@ -368,6 +368,7 @@ export default class IndexedDBCryptoStore {
* is always consistent, so they are stored in one object. * is always consistent, so they are stored in one object.
* *
* @param {Object} deviceData * @param {Object} deviceData
* @param {*} txn An active transaction. See doTxn().
*/ */
storeEndToEndDeviceData(deviceData, txn) { storeEndToEndDeviceData(deviceData, txn) {
this._backendPromise.value().storeEndToEndDeviceData(deviceData, txn); this._backendPromise.value().storeEndToEndDeviceData(deviceData, txn);
@@ -377,9 +378,11 @@ export default class IndexedDBCryptoStore {
* Get the state of all tracked devices * Get the state of all tracked devices
* *
* @param {*} txn An active transaction. See doTxn(). * @param {*} txn An active transaction. See doTxn().
* @param {function(Object)} func Function called with the
* device data
*/ */
getEndToEndDeviceData(txn, func) { getEndToEndDeviceData(txn, func) {
return this._backendPromise.value().getEndToEndDeviceData(txn, func); this._backendPromise.value().getEndToEndDeviceData(txn, func);
} }
/** /**

View File

@@ -702,8 +702,7 @@ SyncApi.prototype._onSyncError = function(err, syncOptions) {
* Process data returned from a sync response and propagate it * Process data returned from a sync response and propagate it
* into the model objects * into the model objects
* *
* @param {string} syncToken the old next_batch token sent to this * @param {Object} syncEventData Object containing sync tokens associated with this sync
* sync request.
* @param {Object} data The response from /sync * @param {Object} data The response from /sync
* @param {bool} isCachedResponse True if this response is from our local cache * @param {bool} isCachedResponse True if this response is from our local cache
*/ */
@@ -950,7 +949,8 @@ SyncApi.prototype._processSyncResponse = async function(
self._deregisterStateListeners(room); self._deregisterStateListeners(room);
room.resetLiveTimeline( room.resetLiveTimeline(
joinObj.timeline.prev_batch, joinObj.timeline.prev_batch,
self.opts.canResetEntireTimeline(room.roomId) ? null : syncEventData.oldSyncToken, self.opts.canResetEntireTimeline(room.roomId) ?
null : syncEventData.oldSyncToken,
); );
// We have to assume any gap in any timeline is // We have to assume any gap in any timeline is
@@ -1046,7 +1046,9 @@ SyncApi.prototype._processSyncResponse = async function(
// Handle device list updates // Handle device list updates
if (data.device_lists) { if (data.device_lists) {
if (this.opts.crypto) { if (this.opts.crypto) {
await this.opts.crypto.handleDeviceListChanges(syncEventData, data.device_lists); await this.opts.crypto.handleDeviceListChanges(
syncEventData, data.device_lists,
);
} else { } else {
// FIXME if we *don't* have a crypto module, we still need to // FIXME if we *don't* have a crypto module, we still need to
// invalidate the device lists. But that would require a // invalidate the device lists. But that would require a