Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import url from 'url';
|
||||
import url from "url";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { compare } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import type { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import SdkConfig from '../SdkConfig';
|
||||
import Modal from '../Modal';
|
||||
import SdkConfig from "../SdkConfig";
|
||||
import Modal from "../Modal";
|
||||
import { IntegrationManagerInstance, Kind } from "./IntegrationManagerInstance";
|
||||
import IntegrationsImpossibleDialog from "../components/views/dialogs/IntegrationsImpossibleDialog";
|
||||
import IntegrationsDisabledDialog from "../components/views/dialogs/IntegrationsDisabledDialog";
|
||||
|
@ -85,24 +85,26 @@ export class IntegrationManagers {
|
|||
|
||||
private setupHomeserverManagers = async (discoveryResponse) => {
|
||||
logger.log("Updating homeserver-configured integration managers...");
|
||||
if (discoveryResponse && discoveryResponse['m.integrations']) {
|
||||
let managers = discoveryResponse['m.integrations']['managers'];
|
||||
if (discoveryResponse && discoveryResponse["m.integrations"]) {
|
||||
let managers = discoveryResponse["m.integrations"]["managers"];
|
||||
if (!Array.isArray(managers)) managers = []; // make it an array so we can wipe the HS managers
|
||||
|
||||
logger.log(`Homeserver has ${managers.length} integration managers`);
|
||||
|
||||
// Clear out any known managers for the homeserver
|
||||
// TODO: Log out of the scalar clients
|
||||
this.managers = this.managers.filter(m => m.kind !== Kind.Homeserver);
|
||||
this.managers = this.managers.filter((m) => m.kind !== Kind.Homeserver);
|
||||
|
||||
// Now add all the managers the homeserver wants us to have
|
||||
for (const hsManager of managers) {
|
||||
if (!hsManager["api_url"]) continue;
|
||||
this.managers.push(new IntegrationManagerInstance(
|
||||
Kind.Homeserver,
|
||||
hsManager["api_url"],
|
||||
hsManager["ui_url"], // optional
|
||||
));
|
||||
this.managers.push(
|
||||
new IntegrationManagerInstance(
|
||||
Kind.Homeserver,
|
||||
hsManager["api_url"],
|
||||
hsManager["ui_url"], // optional
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
this.primaryManager = null; // reset primary
|
||||
|
@ -114,19 +116,19 @@ export class IntegrationManagers {
|
|||
private setupAccountManagers() {
|
||||
if (!this.client || !this.client.getUserId()) return; // not logged in
|
||||
const widgets = WidgetUtils.getIntegrationManagerWidgets();
|
||||
widgets.forEach(w => {
|
||||
const data = w.content['data'];
|
||||
widgets.forEach((w) => {
|
||||
const data = w.content["data"];
|
||||
if (!data) return;
|
||||
|
||||
const uiUrl = w.content['url'];
|
||||
const apiUrl = data['api_url'] as string;
|
||||
const uiUrl = w.content["url"];
|
||||
const apiUrl = data["api_url"] as string;
|
||||
if (!apiUrl || !uiUrl) return;
|
||||
|
||||
const manager = new IntegrationManagerInstance(
|
||||
Kind.Account,
|
||||
apiUrl,
|
||||
uiUrl,
|
||||
w['id'] || w['state_key'] || '',
|
||||
w["id"] || w["state_key"] || "",
|
||||
);
|
||||
this.managers.push(manager);
|
||||
});
|
||||
|
@ -134,7 +136,7 @@ export class IntegrationManagers {
|
|||
}
|
||||
|
||||
private onAccountData = (ev: MatrixEvent): void => {
|
||||
if (ev.getType() === 'm.widgets') {
|
||||
if (ev.getType() === "m.widgets") {
|
||||
this.compileManagers();
|
||||
}
|
||||
};
|
||||
|
@ -146,7 +148,7 @@ export class IntegrationManagers {
|
|||
getOrderedManagers(): IntegrationManagerInstance[] {
|
||||
const ordered = [];
|
||||
for (const kind of KIND_PREFERENCE) {
|
||||
const managers = this.managers.filter(m => m.kind === kind);
|
||||
const managers = this.managers.filter((m) => m.kind === kind);
|
||||
if (!managers || !managers.length) continue;
|
||||
|
||||
if (kind === Kind.Account) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue