Fix Jitsi wellknown hooks

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-06-03 13:58:17 +01:00
parent 5156388fc6
commit a674131a8c
2 changed files with 13 additions and 10 deletions

View file

@ -619,7 +619,7 @@ async function startMatrixClient(startSyncing=true) {
} }
// Now that we have a MatrixClientPeg, update the Jitsi info // Now that we have a MatrixClientPeg, update the Jitsi info
await Jitsi.getInstance().update(); await Jitsi.getInstance().start();
// dispatch that we finished starting up to wire up any other bits // dispatch that we finished starting up to wire up any other bits
// of the matrix client that cannot be set prior to starting up. // of the matrix client that cannot be set prior to starting up.

View file

@ -34,17 +34,20 @@ export class Jitsi {
return this.domain || 'jitsi.riot.im'; return this.domain || 'jitsi.riot.im';
} }
public async update(): Promise<any> { public start() {
const cli = MatrixClientPeg.get();
cli.on("WellKnown.client", this.update);
const discoveryResponse = cli.getClientWellKnown();
if (discoveryResponse) {
// if we missed the first WellKnown.client event then call update anyway
this.update(discoveryResponse);
}
}
private update = async (discoveryResponse): Promise<any> => {
// Start with a default of the config's domain // Start with a default of the config's domain
let domain = (SdkConfig.get()['jitsi'] || {})['preferredDomain'] || 'jitsi.riot.im'; let domain = (SdkConfig.get()['jitsi'] || {})['preferredDomain'] || 'jitsi.riot.im';
const cli = MatrixClientPeg.get();
const discoveryResponse = cli && MatrixClientPeg.get().getClientWellKnown();
if (cli) {
cli.on("WellKnown.client", () => this.update);
}
console.log("Attempting to get Jitsi conference information from homeserver"); console.log("Attempting to get Jitsi conference information from homeserver");
if (discoveryResponse && discoveryResponse[JITSI_WK_PROPERTY]) { if (discoveryResponse && discoveryResponse[JITSI_WK_PROPERTY]) {
const wkPreferredDomain = discoveryResponse[JITSI_WK_PROPERTY]['preferredDomain']; const wkPreferredDomain = discoveryResponse[JITSI_WK_PROPERTY]['preferredDomain'];
@ -54,7 +57,7 @@ export class Jitsi {
// Put the result into memory for us to use later // Put the result into memory for us to use later
this.domain = domain; this.domain = domain;
console.log("Jitsi conference domain:", this.preferredDomain); console.log("Jitsi conference domain:", this.preferredDomain);
} };
/** /**
* Parses the given URL into the data needed for a Jitsi widget, if the widget * Parses the given URL into the data needed for a Jitsi widget, if the widget