Hide virtual widgets from the room info panel (#9424)

This commit is contained in:
Robin 2022-10-14 13:04:29 -04:00 committed by GitHub
parent 3be36acf14
commit aa57d1287d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. 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 classNames from "classnames";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
@ -197,6 +197,8 @@ const AppRow: React.FC<IAppRowProps> = ({ app, room }) => {
const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => { const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
const apps = useWidgets(room); const apps = useWidgets(room);
// Filter out virtual widgets
const realApps = useMemo(() => apps.filter(app => app.eventId !== undefined), [apps]);
const onManageIntegrations = () => { const onManageIntegrations = () => {
const managers = IntegrationManagers.sharedInstance(); const managers = IntegrationManagers.sharedInstance();
@ -208,8 +210,8 @@ const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
} }
}; };
let copyLayoutBtn = null; let copyLayoutBtn: JSX.Element | null = null;
if (apps.length > 0 && WidgetLayoutStore.instance.canCopyLayoutToRoom(room)) { if (realApps.length > 0 && WidgetLayoutStore.instance.canCopyLayoutToRoom(room)) {
copyLayoutBtn = ( copyLayoutBtn = (
<AccessibleButton kind="link" onClick={() => WidgetLayoutStore.instance.copyLayoutToRoom(room)}> <AccessibleButton kind="link" onClick={() => WidgetLayoutStore.instance.copyLayoutToRoom(room)}>
{ _t("Set my room layout for everyone") } { _t("Set my room layout for everyone") }
@ -218,10 +220,10 @@ const AppsSection: React.FC<IAppsSectionProps> = ({ room }) => {
} }
return <Group className="mx_RoomSummaryCard_appsGroup" title={_t("Widgets")}> return <Group className="mx_RoomSummaryCard_appsGroup" title={_t("Widgets")}>
{ apps.map(app => <AppRow key={app.id} app={app} room={room} />) } { realApps.map(app => <AppRow key={app.id} app={app} room={room} />) }
{ copyLayoutBtn } { copyLayoutBtn }
<AccessibleButton kind="link" onClick={onManageIntegrations}> <AccessibleButton kind="link" onClick={onManageIntegrations}>
{ 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") }
</AccessibleButton> </AccessibleButton>
</Group>; </Group>;
}; };