-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add support for hiding videos #29496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
6d5442a
start hide
Half-Shot 9376d71
Move useSettingsValueWithSetter to useSettings
Half-Shot 0cc0645
Add new setting showMediaEventIds
Half-Shot 4d29046
Add a migration path
Half-Shot 72c2a3e
Add an action button to hide settings.
Half-Shot 4e34adb
Tweaks to MImageBody to support new setting.
Half-Shot 7197093
Fixup and add tests
Half-Shot c8b55c3
add description for migration
Half-Shot c759e51
docs fixes
Half-Shot a518c8d
add type
Half-Shot d6fb24d
i18n
Half-Shot 83e421d
appese prettier
Half-Shot e87eb12
Add tests for HideActionButton
Half-Shot cf7e52c
lint
Half-Shot b9c0d63
lint
Half-Shot 46b1234
Merge branch 'develop' into hs/add-hide-image-button
Half-Shot 939ff4e
First pass at support for previewing/hiding images.
Half-Shot debb6ad
Add a test for video files.
Half-Shot 9927406
First pass at supporting hiding video files.
Half-Shot 7696516
Use a hook for media visibility.
Half-Shot ef32747
Drop setting hook usage.
Half-Shot 28ea915
Merge branch 'develop' into hs/add-hide-image-button
Half-Shot d0b8564
Fixup MImageBody test
Half-Shot 571a2e3
Fixup tests
Half-Shot 60eeb8a
Support functional components for message body rendering.
Half-Shot 71257d9
Merge remote-tracking branch 'origin/develop' into hs/add-hide-image-…
Half-Shot 93009d4
Add a comment
Half-Shot d7a185b
Move props into IProps
Half-Shot e057a2e
Merge branch 'hs/add-hide-image-button' into hs/add-hide-image-button…
Half-Shot 6f92b53
Use new wrapping logic
Half-Shot bc264ff
lint
Half-Shot 1b21343
fixup
Half-Shot e939709
allow for a delay for the image to render
Half-Shot c1f0724
remove .only
Half-Shot c6359e6
lint
Half-Shot 265278d
Merge remote-tracking branch 'origin/develop' into hs/add-hide-image-…
Half-Shot 9a0857f
Fix jest test
Half-Shot 89353db
Fixup tests.
Half-Shot 3b27416
make tests happy
Half-Shot 0512bec
Improve comments
Half-Shot 7a423a0
Merge branch 'develop' into hs/add-hide-image-button+video-preview
Half-Shot ab40dc2
Merge remote-tracking branch 'origin/develop' into hs/add-hide-image-…
Half-Shot 75a2c2f
review fixes
Half-Shot 026f40a
unbreak test
Half-Shot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
Copyright 2024, 2025 New Vector Ltd. | ||
Copyright 2022, 2023 The Matrix.org Foundation C.I.C. | ||
|
||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial | ||
|
@@ -28,6 +28,8 @@ | |
const OLD_NAME = "Alan"; | ||
const NEW_NAME = "Alan (away)"; | ||
|
||
const VIDEO_FILE = fs.readFileSync("playwright/sample-files/5secvid.webm"); | ||
|
||
const getEventTilesWithBodies = (page: Page): Locator => { | ||
return page.locator(".mx_EventTile").filter({ has: page.locator(".mx_EventTile_body") }); | ||
}; | ||
|
@@ -403,7 +405,7 @@ | |
await expect(locator).toHaveCSS("min-width", "46px"); | ||
} | ||
// Record alignment of collapsed GELS and messages on messagePanel | ||
await expect(page.locator(".mx_MainSplit")).toMatchScreenshot( | ||
Check failure on line 408 in playwright/e2e/timeline/timeline.spec.ts
|
||
"collapsed-gels-and-messages-irc-layout.png", | ||
{ | ||
// Exclude timestamp from snapshot of mx_MainSplit | ||
|
@@ -909,6 +911,38 @@ | |
mask: [page.locator(".mx_MessageTimestamp")], | ||
}); | ||
}); | ||
|
||
test("should be able to hide an image", { tag: "@screenshot" }, async ({ page, app, room, context }) => { | ||
await app.viewRoomById(room.roomId); | ||
await sendImage(app.client, room.roomId, NEW_AVATAR); | ||
await app.timeline.scrollToBottom(); | ||
const imgTile = page.locator(".mx_MImageBody").first(); | ||
await expect(imgTile).toBeVisible(); | ||
await imgTile.hover(); | ||
await page.getByRole("button", { name: "Hide" }).click(); | ||
|
||
// Check that the image is now hidden. | ||
await expect(page.getByRole("button", { name: "Show image" })).toBeVisible(); | ||
}); | ||
|
||
test("should be able to hide a video", { tag: "@screenshot" }, async ({ page, app, room, context }) => { | ||
await app.viewRoomById(room.roomId); | ||
const upload = await app.client.uploadContent(VIDEO_FILE, { name: "bbb.webm", type: "video/webm" }); | ||
await app.client.sendEvent(room.roomId, null, "m.room.message" as EventType, { | ||
msgtype: "m.video" as MsgType, | ||
body: "bbb.webm", | ||
url: upload.content_uri, | ||
}); | ||
|
||
await app.timeline.scrollToBottom(); | ||
const imgTile = page.locator(".mx_MVideoBody").first(); | ||
await expect(imgTile).toBeVisible(); | ||
await imgTile.hover(); | ||
await page.getByRole("button", { name: "Hide" }).click(); | ||
|
||
// Check that the image is now hidden. | ||
await expect(page.getByRole("button", { name: "Show video" })).toBeVisible(); | ||
Half-Shot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); | ||
|
||
test.describe("message sending", { tag: ["@no-firefox", "@no-webkit"] }, () => { | ||
|
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.mx_HiddenMediaPlaceholder { | ||
border: none; | ||
width: 100%; | ||
height: 100%; | ||
inset: 0; | ||
|
||
/* To center the text in the middle of the frame */ | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-align: center; | ||
|
||
cursor: pointer; | ||
background-color: $header-panel-bg-color; | ||
|
||
> div { | ||
color: $accent; | ||
/* Icon alignment */ | ||
display: flex; | ||
> svg { | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
} | ||
} | ||
} | ||
|
||
.mx_EventTile:hover .mx_HiddenMediaPlaceholder { | ||
background-color: $background; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
Copyright 2025 New Vector Ltd. | ||
|
||
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 React, { type MouseEventHandler } from "react"; | ||
import { VisibilityOnIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; | ||
|
||
import { _t } from "../../../languageHandler"; | ||
|
||
interface IProps { | ||
kind: "m.image" | "m.video"; | ||
onClick: MouseEventHandler<HTMLButtonElement>; | ||
} | ||
|
||
const HiddenMediaPlaceholder: React.FunctionComponent<IProps> = (props) => { | ||
return ( | ||
<button onClick={props.onClick} className="mx_HiddenMediaPlaceholder"> | ||
<div> | ||
<VisibilityOnIcon /> | ||
<span> | ||
{props.kind === "m.image" ? _t("timeline|m.image|show_image") : _t("timeline|m.video|show_video")} | ||
</span> | ||
</div> | ||
</button> | ||
); | ||
}; | ||
|
||
export default HiddenMediaPlaceholder; | ||
Half-Shot marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
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, { useCallback } from "react"; | ||
import classNames from "classnames"; | ||
import { VisibilityOffIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; | ||
|
||
import { RovingAccessibleButton } from "../../../accessibility/RovingTabIndex"; | ||
import { _t } from "../../../languageHandler"; | ||
import { SettingLevel } from "../../../settings/SettingLevel"; | ||
import { useSettingsValueWithSetter, useSettingValue } from "../../../hooks/useSettings"; | ||
|
||
interface IProps { | ||
mxEvent: MatrixEvent; | ||
} | ||
|
||
const HideActionButton: React.FC<IProps> = ({ mxEvent }) => { | ||
const eventId = mxEvent.getId()!; | ||
let spinner: JSX.Element | undefined; | ||
const defaultShowImages = useSettingValue("showImages", SettingLevel.DEVICE); | ||
const [eventVisibility, setEventIds] = useSettingsValueWithSetter("showMediaEventIds", SettingLevel.DEVICE); | ||
const onClick = useCallback(() => { | ||
if (!eventId) { | ||
return; | ||
} | ||
setEventIds({ | ||
...eventVisibility, | ||
[eventId]: false, | ||
}); | ||
}, [setEventIds, eventId, eventVisibility]); | ||
|
||
const classes = classNames({ | ||
mx_MessageActionBar_iconButton: true, | ||
mx_MessageActionBar_downloadButton: true, | ||
mx_MessageActionBar_downloadSpinnerButton: !!spinner, | ||
}); | ||
|
||
const imgIsVisible = | ||
eventVisibility[eventId] === true || (defaultShowImages && eventVisibility[eventId] === undefined); | ||
|
||
if (!imgIsVisible) { | ||
return; | ||
} | ||
|
||
return ( | ||
<RovingAccessibleButton | ||
className={classes} | ||
title={_t("action|hide")} | ||
onClick={onClick} | ||
disabled={!!spinner} | ||
placement="left" | ||
> | ||
<VisibilityOffIcon /> | ||
{spinner} | ||
</RovingAccessibleButton> | ||
); | ||
}; | ||
|
||
export default HideActionButton; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.