From eeb4c5696f1d6bcaa30b9915953d418d31fd91fe Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 10 Sep 2020 14:30:35 +0100 Subject: [PATCH] Don't show 'unpin' for persistent widgets This will mostly fix https://github.com/vector-im/element-web/issues/15139 although it could still break in a race condition. --- .../views/context_menus/WidgetContextMenu.js | 16 +++++++++------- src/components/views/elements/AppTile.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/views/context_menus/WidgetContextMenu.js b/src/components/views/context_menus/WidgetContextMenu.js index 9182b92c8c..6ed32daa5c 100644 --- a/src/components/views/context_menus/WidgetContextMenu.js +++ b/src/components/views/context_menus/WidgetContextMenu.js @@ -26,8 +26,8 @@ export default class WidgetContextMenu extends React.Component { // Callback for when the revoke button is clicked. Required. onRevokeClicked: PropTypes.func.isRequired, - // Callback for when the unpin button is clicked. Required. - onUnpinClicked: PropTypes.func.isRequired, + // Callback for when the unpin button is clicked. If absent, unpin will be hidden. + onUnpinClicked: PropTypes.func, // Callback for when the snapshot button is clicked. Button not shown // without a callback. @@ -86,11 +86,13 @@ export default class WidgetContextMenu extends React.Component { ); } - options.push( - - {_t("Unpin")} - , - ); + if (this.props.onUnpinClicked) { + options.push( + + {_t("Unpin")} + , + ); + } if (this.props.onReloadClicked) { options.push( diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index faca743bfd..02b2c22d4f 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -841,7 +841,7 @@ export default class AppTile extends React.Component { contextMenu = (