-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add ability to hide images after clicking "show image" #29467
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
Conversation
Shouldn't we wait for product approval before doing the review? |
@@ -105,11 +105,6 @@ export default class MFileBody extends React.Component<IProps, IState> { | |||
declare public context: React.ContextType<typeof RoomContext>; | |||
|
|||
public state: IState = {}; | |||
|
|||
public static defaultProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default props would expect showGenericPlaceholder?: boolean
would cause the signature of MFIleBody to expect a parameter for showGenericPlaceholder
, oddly. This breaks 60eeb8a, and rather than leave a bunch of type assertions all over the place, I'll just remove defaultProps.
Since this is a single case, it was easier to just default it in the render function.
@@ -686,3 +685,10 @@ export class HiddenImagePlaceholder extends React.PureComponent<PlaceholderIProp | |||
); | |||
} | |||
} | |||
|
|||
const MImageBody: React.FC<IBodyProps> = (props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a wrapper to use the hook. I decided to defer on rewriting MImageBody in this PR, as it's already kinda huge.
return <MImageBodyInner mediaVisible={mediaVisible} setMediaVisible={setVisible} {...props} />; | ||
}; | ||
|
||
export default MImageBody; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping the same export pattern as the previous class.
@@ -45,8 +45,8 @@ import { type GetRelationsForEvent, type IEventTileOps } from "../rooms/EventTil | |||
// onMessageAllowed is handled internally | |||
interface IProps extends Omit<IBodyProps, "onMessageAllowed" | "mediaEventHelper"> { | |||
/* overrides for the msgtype-specific components, used by ReplyTile to override file rendering */ | |||
overrideBodyTypes?: Record<string, typeof React.Component>; | |||
overrideEventTypes?: Record<string, typeof React.Component>; | |||
overrideBodyTypes?: Record<string, React.ComponentType<IBodyProps>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComponentType allows for both functional and class components.
This adds a simple button to rehide images that may have accidentally been unhidden. This applies regardless of your preview settings, so can be used to hide images that would show by default too.
This comes with a few changes to make this possible, notably:
This PR still needs product review
and tests.Checklist
public
/exported
symbols have accurate TSDoc documentation.