From 9377306b813bdbbeb7bee6e6a52dad6945fea445 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 30 Sep 2020 20:11:27 -0600 Subject: [PATCH] Fix the screenshot button on the right panel card --- src/components/views/right_panel/WidgetCard.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/views/right_panel/WidgetCard.tsx b/src/components/views/right_panel/WidgetCard.tsx index b0eefb0fed..6bb45df109 100644 --- a/src/components/views/right_panel/WidgetCard.tsx +++ b/src/components/views/right_panel/WidgetCard.tsx @@ -39,6 +39,8 @@ import {AppTileActionPayload} from "../../../dispatcher/payloads/AppTileActionPa import {Capability} from "../../../widgets/WidgetApi"; import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import classNames from "classnames"; +import dis from "../../../dispatcher/dispatcher"; +import { WidgetMessagingStore } from "../../../stores/widgets/WidgetMessagingStore"; interface IProps { room: Room; @@ -77,10 +79,17 @@ const WidgetCard: React.FC = ({ room, widgetId, onClose }) => { let contextMenu; if (menuDisplayed) { let snapshotButton; - // TODO: [TravisR] Fix this - if (ActiveWidgetStore.widgetHasCapability(app.id, Capability.Screenshot)) { + const widgetMessaging = WidgetMessagingStore.instance.getMessagingForId(app.id); + if (widgetMessaging?.hasCapability(Capability.Screenshot)) { const onSnapshotClick = () => { - WidgetUtils.snapshotWidget(app); + widgetMessaging.takeScreenshot().then(data => { + dis.dispatch({ + action: 'picture_snapshot', + file: data.screenshot, + }); + }).catch(err => { + console.error("Failed to take screenshot: ", err); + }); closeMenu(); };