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

Commit aa57d12

Browse files
authored
Hide virtual widgets from the room info panel (#9424)
1 parent 3be36ac commit aa57d12

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/components/views/right_panel/RoomSummaryCard.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { useCallback, useContext, useEffect, useState } from "react";
17+
import React, { useCallback, useContext, useEffect, useMemo, useState } from "react";
1818
import classNames from "classnames";
1919
import { Room } from "matrix-js-sdk/src/models/room";
2020

@@ -197,6 +197,8 @@ const AppRow: React.FC<IAppRowProps> = ({ app, room }) => {
197197

198198
const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
199199
const apps = useWidgets(room);
200+
// Filter out virtual widgets
201+
const realApps = useMemo(() => apps.filter(app => app.eventId !== undefined), [apps]);
200202

201203
const onManageIntegrations = () => {
202204
const managers = IntegrationManagers.sharedInstance();
@@ -208,8 +210,8 @@ const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
208210
}
209211
};
210212

211-
let copyLayoutBtn = null;
212-
if (apps.length > 0 && WidgetLayoutStore.instance.canCopyLayoutToRoom(room)) {
213+
let copyLayoutBtn: JSX.Element | null = null;
214+
if (realApps.length > 0 && WidgetLayoutStore.instance.canCopyLayoutToRoom(room)) {
213215
copyLayoutBtn = (
214216
<AccessibleButton kind="link" onClick={() => WidgetLayoutStore.instance.copyLayoutToRoom(room)}>
215217
{ _t("Set my room layout for everyone") }
@@ -218,10 +220,10 @@ const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
218220
}
219221

220222
return <Group className="mx_RoomSummaryCard_appsGroup" title={_t("Widgets")}>
221-
{ apps.map(app => <AppRow key={app.id} app={app} room={room} />) }
223+
{ realApps.map(app => <AppRow key={app.id} app={app} room={room} />) }
222224
{ copyLayoutBtn }
223225
<AccessibleButton kind="link" onClick={onManageIntegrations}>
224-
{ apps.length > 0 ? _t("Edit widgets, bridges & bots") : _t("Add widgets, bridges & bots") }
226+
{ realApps.length > 0 ? _t("Edit widgets, bridges & bots") : _t("Add widgets, bridges & bots") }
225227
</AccessibleButton>
226228
</Group>;
227229
};

0 commit comments

Comments
 (0)