Conform more of the codebase to strictNullChecks + noImplicitAny (#11179)
This commit is contained in:
parent
7c211b0587
commit
a294ba2ad4
17 changed files with 104 additions and 88 deletions
|
@ -49,7 +49,7 @@ export interface IMatrixClientCreds {
|
|||
identityServerUrl?: string;
|
||||
userId: string;
|
||||
deviceId?: string;
|
||||
accessToken?: string;
|
||||
accessToken: string;
|
||||
guest?: boolean;
|
||||
pickleKey?: string;
|
||||
freshLogin?: boolean;
|
||||
|
@ -79,8 +79,6 @@ export interface IMatrixClientPeg {
|
|||
assign(): Promise<any>;
|
||||
start(): Promise<any>;
|
||||
|
||||
getCredentials(): IMatrixClientCreds;
|
||||
|
||||
/**
|
||||
* If we've registered a user ID we set this to the ID of the
|
||||
* user we've just registered. If they then go & log in, we
|
||||
|
@ -138,10 +136,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
|||
private matrixClient: MatrixClient | null = null;
|
||||
private justRegisteredUserId: string | null = null;
|
||||
|
||||
// the credentials used to init the current client object.
|
||||
// used if we tear it down & recreate it with a different store
|
||||
private currentClientCreds: IMatrixClientCreds | null = null;
|
||||
|
||||
public get(): MatrixClient | null {
|
||||
return this.matrixClient;
|
||||
}
|
||||
|
@ -195,7 +189,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
|||
}
|
||||
|
||||
public replaceUsingCreds(creds: IMatrixClientCreds): void {
|
||||
this.currentClientCreds = creds;
|
||||
this.createClient(creds);
|
||||
}
|
||||
|
||||
|
@ -335,29 +328,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
|||
logger.log(`MatrixClientPeg: MatrixClient started`);
|
||||
}
|
||||
|
||||
public getCredentials(): IMatrixClientCreds {
|
||||
if (!this.matrixClient) {
|
||||
throw new Error("createClient must be called first");
|
||||
}
|
||||
|
||||
let copiedCredentials: IMatrixClientCreds | null = this.currentClientCreds;
|
||||
if (this.currentClientCreds?.userId !== this.matrixClient?.credentials?.userId) {
|
||||
// cached credentials belong to a different user - don't use them
|
||||
copiedCredentials = null;
|
||||
}
|
||||
return {
|
||||
// Copy the cached credentials before overriding what we can.
|
||||
...(copiedCredentials ?? {}),
|
||||
|
||||
homeserverUrl: this.matrixClient.baseUrl,
|
||||
identityServerUrl: this.matrixClient.idBaseUrl,
|
||||
userId: this.matrixClient.getSafeUserId(),
|
||||
deviceId: this.matrixClient.getDeviceId() ?? undefined,
|
||||
accessToken: this.matrixClient.getAccessToken() ?? undefined,
|
||||
guest: this.matrixClient.isGuest(),
|
||||
};
|
||||
}
|
||||
|
||||
public getHomeserverName(): string {
|
||||
const matches = /^@[^:]+:(.+)$/.exec(this.safeGet().getSafeUserId());
|
||||
if (matches === null || matches.length < 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue