matrix-dimension/web/app/configs/widget/widget.component.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

import { ScalarService } from "../../shared/scalar.service";
import { Widget, ScalarToWidgets } from "../../shared/models/widget";
export const SCALAR_WIDGET_LINKS = [
2017-10-10 04:00:29 +00:00
"https://scalar-staging.riot.im/scalar/api/widgets/generic.html?url=",
"https://scalar-staging.vector.im/scalar/api/widgets/generic.html?url=",
"https://scalar-develop.riot.im/scalar/api/widgets/generic.html?url=",
"https://demo.riot.im/scalar/api/widgets/generic.html?url=",
];
export class WidgetComponent {
constructor(protected scalarApi: ScalarService, protected roomId: string) {
}
protected getWidgetsOfType(type: string, altType: string = null): Promise<Widget[]> {
return this.scalarApi.getWidgets(this.roomId)
.then(resp => ScalarToWidgets(resp))
.then(widgets => {
let filtered: Widget[] = [];
for (let widget of widgets) {
if (widget.type === type || (altType && widget.type === altType))
filtered.push(widget);
}
return filtered;
});
}
}