mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
c9571576fe
Adds #91
24 lines
776 B
TypeScript
24 lines
776 B
TypeScript
import { ScalarService } from "../../shared/scalar.service";
|
|
import { Widget, ScalarToWidgets } from "../../shared/models/widget";
|
|
|
|
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;
|
|
});
|
|
}
|
|
}
|