Skip to content

Commit

Permalink
Fix remaining hot paths
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Jun 2, 2021
1 parent e4de5ab commit 56bf57b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
29 changes: 14 additions & 15 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export class MatrixClient extends EventEmitter {
}
return this.canResetTimelineCallback(roomId);
};
this.syncApi = new SyncApi(this, opts);
this.syncApi = new SyncApi(this, this.clientOpts);
this.syncApi.sync();

if (opts.clientWellKnownPollPeriod !== undefined) {
Expand Down Expand Up @@ -1420,6 +1420,13 @@ export class MatrixClient extends EventEmitter {
return this.crypto.beginKeyVerification(method, userId, deviceId);
}

public checkSecretStorageKey(key: any, info: any): Promise<any> { // TODO: Types
if (!this.crypto) {
throw new Error("End-to-end encryption disabled");
}
return this.crypto.checkSecretStorageKey(key, info);
}

/**
* Set the global override for whether the client should ever send encrypted
* messages to unverified devices. This provides the default for rooms which
Expand Down Expand Up @@ -4876,14 +4883,7 @@ export class MatrixClient extends EventEmitter {
highlights: [],
};

// TODO: @@TR: wtf is this
// prev:
/*
return this.search({ body: body }).then(
this._processRoomEventsSearch.bind(this, searchResults),
);
*/
return this.search({ body: body }).then(res => this.processRoomEventsSearch(res, searchResults));
return this.search({ body: body }).then(res => this.processRoomEventsSearch(searchResults, res));
}

/**
Expand Down Expand Up @@ -4911,12 +4911,11 @@ export class MatrixClient extends EventEmitter {
next_batch: searchResults.next_batch,
};

// TODO: @@TR: wtf
const promise = this.search(searchOpts).then(
this.processRoomEventsSearch.bind(this, searchResults),
).finally(() => {
searchResults.pendingRequest = null;
});
const promise = this.search(searchOpts)
.then(res => this.processRoomEventsSearch(searchResults, res))
.finally(() => {
searchResults.pendingRequest = null;
});
searchResults.pendingRequest = promise;

return promise;
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/SecretStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export class SecretStorage extends EventEmitter {
&& this._incomingRequests[deviceId][content.request_id]) {
logger.info("received request cancellation for secret (" + sender
+ ", " + deviceId + ", " + content.request_id + ")");
this.baseApis.emit("crypto.secrets.requestCancelled", {
this._baseApis.emit("crypto.secrets.requestCancelled", {
user_id: sender,
device_id: deviceId,
request_id: content.request_id,
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ Crypto.prototype.bootstrapCrossSigning = async function({
} = {}) {
logger.log("Bootstrapping cross-signing");

const delegateCryptoCallbacks = this.baseApis.cryptoCallbacks;
const delegateCryptoCallbacks = this._baseApis.cryptoCallbacks;
const builder = new EncryptionSetupBuilder(
this._baseApis.store.accountData,
delegateCryptoCallbacks,
Expand Down

0 comments on commit 56bf57b

Please sign in to comment.