Conform more code to strict null checking (#10167)
* Conform more code to strict null checking * Delint * Iterate PR based on feedback
This commit is contained in:
parent
f7bea2cae5
commit
4574c665ea
103 changed files with 517 additions and 495 deletions
|
@ -33,18 +33,13 @@ export enum Kind {
|
|||
}
|
||||
|
||||
export class IntegrationManagerInstance {
|
||||
public readonly apiUrl: string;
|
||||
public readonly uiUrl: string;
|
||||
public readonly kind: string;
|
||||
public readonly id: string; // only applicable in some cases
|
||||
|
||||
// Per the spec: UI URL is optional.
|
||||
public constructor(kind: string, apiUrl: string, uiUrl: string = apiUrl, id?: string) {
|
||||
this.kind = kind;
|
||||
this.apiUrl = apiUrl;
|
||||
this.uiUrl = uiUrl;
|
||||
this.id = id;
|
||||
}
|
||||
public constructor(
|
||||
public readonly kind: string,
|
||||
public readonly apiUrl: string,
|
||||
public readonly uiUrl: string = apiUrl,
|
||||
public readonly id?: string, // only applicable in some cases
|
||||
) {}
|
||||
|
||||
public get name(): string {
|
||||
const parsed = url.parse(this.uiUrl);
|
||||
|
@ -62,7 +57,7 @@ export class IntegrationManagerInstance {
|
|||
return new ScalarAuthClient(this.apiUrl, this.uiUrl);
|
||||
}
|
||||
|
||||
public async open(room: Room = null, screen: string = null, integrationId: string = null): Promise<void> {
|
||||
public async open(room: Room, screen?: string, integrationId?: string): Promise<void> {
|
||||
if (!SettingsStore.getValue("integrationProvisioning")) {
|
||||
return IntegrationManagers.sharedInstance().showDisabledDialog();
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ export class IntegrationManagers {
|
|||
|
||||
private managers: IntegrationManagerInstance[] = [];
|
||||
private client: MatrixClient;
|
||||
private primaryManager: IntegrationManagerInstance;
|
||||
private primaryManager: IntegrationManagerInstance | null;
|
||||
|
||||
public static sharedInstance(): IntegrationManagers {
|
||||
if (!IntegrationManagers.instance) {
|
||||
|
@ -146,7 +146,7 @@ export class IntegrationManagers {
|
|||
}
|
||||
|
||||
public getOrderedManagers(): IntegrationManagerInstance[] {
|
||||
const ordered = [];
|
||||
const ordered: IntegrationManagerInstance[] = [];
|
||||
for (const kind of KIND_PREFERENCE) {
|
||||
const managers = this.managers.filter((m) => m.kind === kind);
|
||||
if (!managers || !managers.length) continue;
|
||||
|
@ -161,7 +161,7 @@ export class IntegrationManagers {
|
|||
return ordered;
|
||||
}
|
||||
|
||||
public getPrimaryManager(): IntegrationManagerInstance {
|
||||
public getPrimaryManager(): IntegrationManagerInstance | null {
|
||||
if (this.hasManager()) {
|
||||
if (this.primaryManager) return this.primaryManager;
|
||||
|
||||
|
@ -195,7 +195,7 @@ export class IntegrationManagers {
|
|||
* @returns {Promise<IntegrationManagerInstance>} Resolves to an integration manager instance,
|
||||
* or null if none was found.
|
||||
*/
|
||||
public async tryDiscoverManager(domainName: string): Promise<IntegrationManagerInstance> {
|
||||
public async tryDiscoverManager(domainName: string): Promise<IntegrationManagerInstance | null> {
|
||||
logger.log("Looking up integration manager via .well-known");
|
||||
if (domainName.startsWith("http:") || domainName.startsWith("https:")) {
|
||||
// trim off the scheme and just use the domain
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue