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

Fetch server capabilities during client initialisation (#2093)

This commit is contained in:
Germain
2022-01-11 11:53:30 +00:00
committed by GitHub
parent 9b54df7b2b
commit cfd865bf8b
12 changed files with 90 additions and 78 deletions

View File

@@ -411,14 +411,19 @@ export interface IRoomVersionsCapability {
"org.matrix.msc3244.room_capabilities"?: Record<string, IRoomCapability>; // MSC3244
}
export interface IChangePasswordCapability {
export interface ICapability {
enabled: boolean;
}
export interface IChangePasswordCapability extends ICapability {}
export interface IThreadsCapability extends ICapability {}
interface ICapabilities {
[key: string]: any;
"m.change_password"?: IChangePasswordCapability;
"m.room_versions"?: IRoomVersionsCapability;
"io.element.thread"?: IThreadsCapability;
}
/* eslint-disable camelcase */
@@ -996,7 +1001,7 @@ export class MatrixClient extends EventEmitter {
* state change events.
* @param {Object=} opts Options to apply when syncing.
*/
public async startClient(opts: IStartClientOpts) {
public async startClient(opts: IStartClientOpts): Promise<void> {
if (this.clientRunning) {
// client is already running.
return;
@@ -1036,6 +1041,8 @@ export class MatrixClient extends EventEmitter {
this.syncApi.stop();
}
await this.getCapabilities(true);
// shallow-copy the opts dict before modifying and storing it
this.clientOpts = Object.assign({}, opts) as IStoredClientOpts;
this.clientOpts.crypto = this.crypto;