2025-03-18 14:23:24 +00:00
|
|
|
/*
|
2025-04-22 10:37:47 +01:00
|
|
|
Copyright 2024, 2025 New Vector Ltd.
|
2025-03-18 14:23:24 +00:00
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { type MatrixEvent } from "matrix-js-sdk/src/matrix";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { VisibilityOffIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
|
|
|
|
|
|
|
|
|
import { RovingAccessibleButton } from "../../../accessibility/RovingTabIndex";
|
|
|
|
|
import { _t } from "../../../languageHandler";
|
|
|
|
|
import { useMediaVisible } from "../../../hooks/useMediaVisible";
|
|
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
/**
|
|
|
|
|
* Matrix event that this action applies to.
|
|
|
|
|
*/
|
|
|
|
|
mxEvent: MatrixEvent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Quick action button for marking a media event as hidden.
|
|
|
|
|
*/
|
|
|
|
|
export const HideActionButton: React.FC<IProps> = ({ mxEvent }) => {
|
2025-04-22 10:37:47 +01:00
|
|
|
const [mediaIsVisible, setVisible] = useMediaVisible(mxEvent.getId(), mxEvent.getRoomId());
|
2025-03-18 14:23:24 +00:00
|
|
|
|
|
|
|
|
if (!mediaIsVisible) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<RovingAccessibleButton
|
|
|
|
|
className="mx_MessageActionBar_iconButton "
|
|
|
|
|
title={_t("action|hide")}
|
|
|
|
|
onClick={() => setVisible(false)}
|
|
|
|
|
placement="left"
|
|
|
|
|
>
|
|
|
|
|
<VisibilityOffIcon />
|
|
|
|
|
</RovingAccessibleButton>
|
|
|
|
|
);
|
|
|
|
|
};
|