diff --git a/src/MatrixClientPeg.ts b/src/MatrixClientPeg.ts index f19fa0c162..d14003dbfa 100644 --- a/src/MatrixClientPeg.ts +++ b/src/MatrixClientPeg.ts @@ -73,22 +73,44 @@ export interface IMatrixClientCreds { * you'll find a `MatrixClient` hanging on the `MatrixClientPeg`. */ export interface IMatrixClientPeg { + /** + * The opts used to start the client + */ opts: IStartClientOpts; /** * Return the server name of the user's homeserver * Throws an error if unable to deduce the homeserver name - * (eg. if the user is not logged in) + * (e.g. if the user is not logged in) * * @returns {string} The homeserver name, if present. */ getHomeserverName(): string; + /** + * Get the current MatrixClient, if any + */ get(): MatrixClient | null; + + /** + * Get the current MatrixClient, throwing an error if there isn't one + */ safeGet(): MatrixClient; + + /** + * Unset the current MatrixClient + */ unset(): void; - assign(): Promise; - start(): Promise; + + /** + * Prepare the MatrixClient for use, including initialising the store and crypto, but do not start it + */ + assign(): Promise; + + /** + * Prepare the MatrixClient for use, including initialising the store and crypto, and start it + */ + start(): Promise; /** * If we've registered a user ID we set this to the ID of the @@ -235,7 +257,7 @@ class MatrixClientPegClass implements IMatrixClientPeg { PlatformPeg.get()?.reload(); }; - public async assign(): Promise { + public async assign(): Promise { if (!this.matrixClient) { throw new Error("createClient must be called first"); } @@ -354,7 +376,7 @@ class MatrixClientPegClass implements IMatrixClientPeg { } } - public async start(): Promise { + public async start(): Promise { const opts = await this.assign(); logger.log(`MatrixClientPeg: really starting MatrixClient`);