matrix-dimension/web/app/widget-wrappers/capable-widget.ts
Travis Ralston 6c4e8f75d4 Add a sticker picker
The useful bit for sending stickers. Implements the rest of #156
2018-05-13 22:32:13 -06:00

29 lines
1020 B
TypeScript

import { OnDestroy, OnInit } from "@angular/core";
import { Subscription } from "rxjs/Subscription";
import { ScalarWidgetApi } from "../shared/services/scalar/scalar-widget.api";
export abstract class CapableWidget implements OnInit, OnDestroy {
private widgetApiSubscription: Subscription;
// The capabilities we support
protected supportsScreenshots = false;
protected supportsStickers = false;
public ngOnInit() {
this.widgetApiSubscription = ScalarWidgetApi.requestReceived.subscribe(request => {
if (request.action === "capabilities") {
const capabilities = [];
if (this.supportsScreenshots) capabilities.push("m.capability.screenshot");
if (this.supportsStickers) capabilities.push("m.sticker");
ScalarWidgetApi.replyCapabilities(request, capabilities);
}
});
}
public ngOnDestroy() {
if (this.widgetApiSubscription) this.widgetApiSubscription.unsubscribe();
}
}