Consolidate TileShape into TimelineRenderingType (#7843)

This commit is contained in:
Michael Telatynski 2022-02-18 15:56:05 +00:00 committed by GitHub
parent ca89d3b96e
commit 5f5bb4a4fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 174 additions and 154 deletions

View file

@ -28,6 +28,7 @@ import { IBodyProps } from "./IBodyProps";
import { PlaybackManager } from "../../../audio/PlaybackManager";
import { isVoiceMessage } from "../../../utils/EventUtils";
import { PlaybackQueue } from "../../../audio/PlaybackQueue";
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
interface IState {
error?: Error;
@ -36,6 +37,9 @@ interface IState {
@replaceableComponent("views.messages.MAudioBody")
export default class MAudioBody extends React.PureComponent<IBodyProps, IState> {
static contextType = RoomContext;
public context!: React.ContextType<typeof RoomContext>;
constructor(props: IBodyProps) {
super(props);
@ -82,6 +86,12 @@ export default class MAudioBody extends React.PureComponent<IBodyProps, IState>
this.state.playback?.destroy();
}
protected get showFileBody(): boolean {
return this.context.timelineRenderingType !== TimelineRenderingType.Room &&
this.context.timelineRenderingType !== TimelineRenderingType.Pinned &&
this.context.timelineRenderingType !== TimelineRenderingType.Search;
}
public render() {
if (this.state.error) {
return (
@ -115,7 +125,7 @@ export default class MAudioBody extends React.PureComponent<IBodyProps, IState>
return (
<span className="mx_MAudioBody">
<AudioPlayer playback={this.state.playback} mediaName={this.props.mxEvent.getContent().body} />
{ this.props.tileShape && <MFileBody {...this.props} showGenericPlaceholder={false} /> }
{ this.showFileBody && <MFileBody {...this.props} showGenericPlaceholder={false} /> }
</span>
);
}