Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
implement RequiresClient capability Fix #15744
Browse files Browse the repository at this point in the history
On request, Element disables the Popout button, this guarantees that the widgetApi is available.
  • Loading branch information
toger5 committed Oct 22, 2021
1 parent d188d32 commit 7243e34
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default class WidgetCapabilitiesPromptDialog extends React.PureComponent<

return 0;
});
// const filteredCapabilites = //TODO this would be where the NoPopout capability text can be hidden and approved by default
const checkboxRows = orderedCapabilities.map(([cap, isChecked], i) => {
const text = CapabilityText.for(cap, this.props.widgetKind);
const byline = text.byline
Expand Down
7 changes: 6 additions & 1 deletion src/components/views/elements/AppTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface IState {
error: Error;
menuDisplayed: boolean;
widgetPageTitle: string;
noPopout: boolean;
}

import { logger } from "matrix-js-sdk/src/logger";
Expand Down Expand Up @@ -155,6 +156,7 @@ export default class AppTile extends React.Component<IProps, IState> {
error: null,
menuDisplayed: false,
widgetPageTitle: this.props.widgetPageTitle,
noPopout: true,
};
}

Expand Down Expand Up @@ -295,6 +297,9 @@ export default class AppTile extends React.Component<IProps, IState> {
if (WidgetType.JITSI.matches(this.props.app.type)) {
this.sgWidget.widgetApi.transport.send(ElementWidgetActions.ClientReady, {});
}
this.setState({
noPopout: this.sgWidget.widgetApi.hasCapability(MatrixCapabilities.RequiresClient)
});
};

private onAction = (payload): void => {
Expand Down Expand Up @@ -512,7 +517,7 @@ export default class AppTile extends React.Component<IProps, IState> {
{ this.props.showTitle && this.getTileTitle() }
</span>
<span className="mx_AppTileMenuBarWidgets">
{ this.props.showPopout && <AccessibleButton
{(this.props.showPopout && !this.state.noPopout) && <AccessibleButton
className="mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton_popout"
title={_t('Popout widget')}
onClick={this.onPopoutWidgetClick}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/widgets/StopGapWidgetDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
// Always allow screenshots to be taken because it's a client-induced flow. The widget can't
// spew screenshots at us and can't request screenshots of us, so it's up to us to provide the
// button if the widget says it supports screenshots.
this.allowedCapabilities = new Set([...allowedCapabilities, MatrixCapabilities.Screenshots]);
this.allowedCapabilities = new Set([...allowedCapabilities, MatrixCapabilities.Screenshots, MatrixCapabilities.RequiresClient]);

// Grant the permissions that are specific to given widget types
if (WidgetType.JITSI.matches(this.forWidget.type) && forWidgetKind === WidgetKind.Room) {
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/CapabilityText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class CapabilityText {
[MatrixCapabilities.MSC2931Navigate]: {
[GENERIC_WIDGET_KIND]: _td("Change which room, message, or user you're viewing"),
},
[MatrixCapabilities.RequiresClient]: {
[GENERIC_WIDGET_KIND]: _td("Prohibits Element from showing the widget popout button."),
},
};

private static stateSendRecvCaps: ISendRecvStaticCapText = {
Expand Down

0 comments on commit 7243e34

Please sign in to comment.