From 0b4c692d17367ab2da414ddbab5dad13cd2f2f6c Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Fri, 14 Oct 2022 11:59:32 -0400 Subject: [PATCH] Hide virtual widgets from the room info panel --- src/components/views/right_panel/RoomSummaryCard.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index 05316ffff65..006a00f3a2f 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React, { useCallback, useContext, useEffect, useState } from "react"; +import React, { useCallback, useContext, useEffect, useMemo, useState } from "react"; import classNames from "classnames"; import { Room } from "matrix-js-sdk/src/models/room"; @@ -197,6 +197,8 @@ const AppRow: React.FC = ({ app, room }) => { const AppsSection: React.FC = ({ room }) => { const apps = useWidgets(room); + // Filter out virtual widgets + const realApps = useMemo(() => apps.filter(app => app.eventId !== undefined), [apps]); const onManageIntegrations = () => { const managers = IntegrationManagers.sharedInstance(); @@ -208,8 +210,8 @@ const AppsSection: React.FC = ({ room }) => { } }; - let copyLayoutBtn = null; - if (apps.length > 0 && WidgetLayoutStore.instance.canCopyLayoutToRoom(room)) { + let copyLayoutBtn: JSX.Element | null = null; + if (realApps.length > 0 && WidgetLayoutStore.instance.canCopyLayoutToRoom(room)) { copyLayoutBtn = ( WidgetLayoutStore.instance.copyLayoutToRoom(room)}> { _t("Set my room layout for everyone") } @@ -218,10 +220,10 @@ const AppsSection: React.FC = ({ room }) => { } return - { apps.map(app => ) } + { realApps.map(app => ) } { copyLayoutBtn } - { apps.length > 0 ? _t("Edit widgets, bridges & bots") : _t("Add widgets, bridges & bots") } + { realApps.length > 0 ? _t("Edit widgets, bridges & bots") : _t("Add widgets, bridges & bots") } ; };