You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Hide virtual widgets from the room info panel (#9424)
This commit is contained in:
@@ -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>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user