Skip to content
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

Inhibit interactions on forward dialog message previews #11025

Merged
merged 6 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/views/dialogs/ForwardDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
mx_IRCLayout: previewLayout == Layout.IRC,
})}
>
<EventTile mxEvent={mockEvent} layout={previewLayout} permalinkCreator={permalinkCreator} as="div" />
<EventTile
mxEvent={mockEvent}
layout={previewLayout}
permalinkCreator={permalinkCreator}
as="div"
inhibitInteraction
/>
</div>
<hr />
<div className="mx_ForwardList" id="mx_ForwardList">
Expand Down
3 changes: 3 additions & 0 deletions src/components/views/messages/IBodyProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ export interface IBodyProps {
getRelationsForEvent?: GetRelationsForEvent;

ref?: React.RefObject<any> | LegacyRef<any>;

// Used by EventTilePreview to disable interactions and tab indexes
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
inhibitInteraction?: boolean;
}
4 changes: 2 additions & 2 deletions src/components/views/messages/MVideoBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>

public render(): React.ReactNode {
const content = this.props.mxEvent.getContent();
const autoplay = SettingsStore.getValue("autoplayVideo");
const autoplay = !this.props.inhibitInteraction && SettingsStore.getValue("autoplayVideo");

let aspectRatio;
if (content.info?.w && content.info?.h) {
Expand Down Expand Up @@ -287,7 +287,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
ref={this.videoRef}
src={contentUrl}
title={content.body}
controls
controls={!this.props.inhibitInteraction}
// Disable downloading as it doesn't work with e2ee video,
// users should use the dedicated Download button in the Message Action Bar
controlsList="nodownload"
Expand Down
1 change: 1 addition & 0 deletions src/components/views/messages/MessageEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
const content = this.props.mxEvent.getContent();
const type = this.props.mxEvent.getType();
const msgtype = content.msgtype;
let BodyType: React.ComponentType<Partial<IBodyProps>> | ReactAnyComponent = RedactedBody;

Check failure on line 156 in src/components/views/messages/MessageEvent.tsx

View workflow job for this annotation

GitHub Actions / Typescript Strict Error Checker

Type 'ForwardRefExoticComponent<(IProps | Pick<IBodyProps, "replacingEventId" | "mxEvent" | "highlights" | "highlightLink" | "onHeightChanged" | "showUrlPreview" | "forExport" | "maxImageHeight" | "editState" | "onMessageAllowed" | "permalinkCreator" | "mediaEventHelper" | "isSeeingThroughMessageHiddenForModeration" | "getRelationsForEvent" | "inhibitInteraction">) & RefAttributes<any>>' is not assignable to type 'ExoticComponent<{}>'. Types of parameters 'props' and 'props' are incompatible. Type '{}' is not assignable to type '(IProps | Pick<IBodyProps, "replacingEventId" | "mxEvent" | "highlights" | "highlightLink" | "onHeightChanged" | "showUrlPreview" | "forExport" | "maxImageHeight" | "editState" | "onMessageAllowed" | "permalinkCreator" | "mediaEventHelper" | "isSeeingThroughMessageHiddenForModeration" | "getRelationsForEvent" | "inhibitInteraction">) & RefAttributes<any>'.

src/components/views/messages/MessageEvent.tsx:156:13 - Type 'ForwardRefExoticComponent<(IProps | Pick<IBodyProps, "replacingEventId" | "mxEvent" | "highlights" | "highlightLink" | "onHeightChanged" | "showUrlPreview" | "forExport" | "maxImageHeight" | "editState" | "onMessageAllowed" | "permalinkCreator" | "mediaEventHelper" | "isSeeingThroughMessageHiddenForModeration" | "getRelationsForEvent" | "inhibitInteraction">) & RefAttributes<any>>' is not assignable to type 'ReactAnyComponent | ComponentType<Partial<IBodyProps>>'.
if (!this.props.mxEvent.isRedacted()) {
// only resolve BodyType if event is not redacted
if (this.props.mxEvent.isDecryptionFailure()) {
Expand Down Expand Up @@ -213,6 +213,7 @@
mediaEventHelper={this.mediaHelper}
getRelationsForEvent={this.props.getRelationsForEvent}
isSeeingThroughMessageHiddenForModeration={this.props.isSeeingThroughMessageHiddenForModeration}
inhibitInteraction={this.props.inhibitInteraction}
/>
) : null;
}
Expand Down
4 changes: 4 additions & 0 deletions src/events/EventTileFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface EventTileTypeProps {
maxImageHeight?: number; // pixels
overrideBodyTypes?: Record<string, typeof React.Component>;
overrideEventTypes?: Record<string, typeof React.Component>;
inhibitInteraction?: boolean;
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
}

type FactoryProps = Omit<EventTileTypeProps, "ref">;
Expand Down Expand Up @@ -322,6 +323,7 @@ export function renderTile(
getRelationsForEvent,
isSeeingThroughMessageHiddenForModeration,
timestamp,
inhibitInteraction,
} = props;

switch (renderType) {
Expand All @@ -340,6 +342,7 @@ export function renderTile(
getRelationsForEvent,
isSeeingThroughMessageHiddenForModeration,
permalinkCreator,
inhibitInteraction,
});
default:
// NEARLY ALL THE OPTIONS!
Expand All @@ -357,6 +360,7 @@ export function renderTile(
getRelationsForEvent,
isSeeingThroughMessageHiddenForModeration,
timestamp,
inhibitInteraction,
});
}
}
Expand Down
Loading