Improve comments and types in MatrixClientPeg (#12477)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/28217/head
Michael Telatynski 2024-05-01 14:22:29 +01:00 committed by GitHub
parent 74e7195a61
commit 5dc3ad546c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 5 deletions

View File

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