diff --git a/src/components/views/context_menus/WidgetContextMenu.tsx b/src/components/views/context_menus/WidgetContextMenu.tsx index 4a704e38e1..f47871d4b5 100644 --- a/src/components/views/context_menus/WidgetContextMenu.tsx +++ b/src/components/views/context_menus/WidgetContextMenu.tsx @@ -82,8 +82,11 @@ const WidgetContextMenu: React.FC = ({ />; } + const pinnedWidgets = WidgetLayoutStore.instance.getContainerWidgets(room, Container.Top); + const widgetIndex = pinnedWidgets.findIndex(widget => widget.id === app.id); + let unpinButton; - if (showUnpin) { + if (showUnpin && widgetIndex >= 0) { const onUnpinClick = () => { WidgetLayoutStore.instance.moveToContainer(room, app, Container.Right); onFinished(); @@ -175,9 +178,6 @@ const WidgetContextMenu: React.FC = ({ revokeButton = ; } - const pinnedWidgets = WidgetLayoutStore.instance.getContainerWidgets(room, Container.Top); - const widgetIndex = pinnedWidgets.findIndex(widget => widget.id === app.id); - let moveLeftButton; if (showUnpin && widgetIndex > 0) { const onClick = () => { diff --git a/src/components/views/elements/AppTile.tsx b/src/components/views/elements/AppTile.tsx index fbe092c7b5..0db5a275b3 100644 --- a/src/components/views/elements/AppTile.tsx +++ b/src/components/views/elements/AppTile.tsx @@ -39,7 +39,7 @@ import PersistedElement, { getPersistKey } from "./PersistedElement"; import { WidgetType } from "../../../widgets/WidgetType"; import { StopGapWidget } from "../../../stores/widgets/StopGapWidget"; import { ElementWidgetActions } from "../../../stores/widgets/ElementWidgetActions"; -import RoomWidgetContextMenu from "../context_menus/WidgetContextMenu"; +import WidgetContextMenu from "../context_menus/WidgetContextMenu"; import WidgetAvatar from "../avatars/WidgetAvatar"; import { replaceableComponent } from "../../../utils/replaceableComponent"; import CallHandler from '../../../CallHandler'; @@ -573,7 +573,7 @@ export default class AppTile extends React.Component { let contextMenu; if (this.state.menuDisplayed) { contextMenu = ( -