Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit fe2eb5e

Browse files
authored
Merge pull request #6370 from matrix-org/travis/voice_messages/right-panel
Fix voice messages in right panels
2 parents 2b8e709 + 1f131db commit fe2eb5e

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

res/css/views/audio_messages/_PlaybackContainer.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@ limitations under the License.
4949
padding-right: 6px; // with the fixed width this ends up as a visual 8px most of the time, as intended.
5050
padding-left: 8px; // isolate from recording circle / play control
5151
}
52+
53+
&.mx_VoiceMessagePrimaryContainer_noWaveform {
54+
max-width: 162px; // with all the padding this results in 185px wide
55+
}
5256
}

src/components/views/audio_messages/RecordingPlayback.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ limitations under the License.
1717
import { Playback, PlaybackState } from "../../../voice/Playback";
1818
import React, { ReactNode } from "react";
1919
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
20-
import PlaybackWaveform from "./PlaybackWaveform";
2120
import PlayPauseButton from "./PlayPauseButton";
2221
import PlaybackClock from "./PlaybackClock";
2322
import { replaceableComponent } from "../../../utils/replaceableComponent";
23+
import { TileShape } from "../rooms/EventTile";
24+
import PlaybackWaveform from "./PlaybackWaveform";
2425

2526
interface IProps {
2627
// Playback instance to render. Cannot change during component lifecycle: create
2728
// an all-new component instead.
2829
playback: Playback;
30+
31+
tileShape?: TileShape;
2932
}
3033

3134
interface IState {
@@ -50,15 +53,22 @@ export default class RecordingPlayback extends React.PureComponent<IProps, IStat
5053
this.props.playback.prepare();
5154
}
5255

56+
private get isWaveformable(): boolean {
57+
return this.props.tileShape !== TileShape.Notif
58+
&& this.props.tileShape !== TileShape.FileGrid
59+
&& this.props.tileShape !== TileShape.Pinned;
60+
}
61+
5362
private onPlaybackUpdate = (ev: PlaybackState) => {
5463
this.setState({ playbackPhase: ev });
5564
};
5665

5766
public render(): ReactNode {
58-
return <div className='mx_MediaBody mx_VoiceMessagePrimaryContainer'>
67+
const shapeClass = !this.isWaveformable ? 'mx_VoiceMessagePrimaryContainer_noWaveform' : '';
68+
return <div className={'mx_MediaBody mx_VoiceMessagePrimaryContainer ' + shapeClass}>
5969
<PlayPauseButton playback={this.props.playback} playbackPhase={this.state.playbackPhase} />
6070
<PlaybackClock playback={this.props.playback} />
61-
<PlaybackWaveform playback={this.props.playback} />
71+
{ this.isWaveformable && <PlaybackWaveform playback={this.props.playback} /> }
6272
</div>;
6373
}
6474
}

src/components/views/messages/MVoiceMessageBody.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import { mediaFromContent } from "../../../customisations/Media";
2525
import { decryptFile } from "../../../utils/DecryptFile";
2626
import RecordingPlayback from "../audio_messages/RecordingPlayback";
2727
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
28+
import { TileShape } from "../rooms/EventTile";
2829

2930
interface IProps {
3031
mxEvent: MatrixEvent;
32+
tileShape?: TileShape;
3133
}
3234

3335
interface IState {
@@ -103,7 +105,7 @@ export default class MVoiceMessageBody extends React.PureComponent<IProps, IStat
103105
// At this point we should have a playable state
104106
return (
105107
<span className="mx_MVoiceMessageBody">
106-
<RecordingPlayback playback={this.state.playback} />
108+
<RecordingPlayback playback={this.state.playback} tileShape={this.props.tileShape} />
107109
<MFileBody {...this.props} decryptedBlob={this.state.decryptedBlob} showGenericPlaceholder={false} />
108110
</span>
109111
);

src/components/views/rooms/EventTile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export enum TileShape {
194194
FileGrid = "file_grid",
195195
Reply = "reply",
196196
ReplyPreview = "reply_preview",
197+
Pinned = "pinned",
197198
}
198199

199200
interface IProps {
@@ -1097,6 +1098,7 @@ export default class EventTile extends React.Component<IProps, IState> {
10971098
highlightLink={this.props.highlightLink}
10981099
showUrlPreview={this.props.showUrlPreview}
10991100
onHeightChanged={this.props.onHeightChanged}
1101+
tileShape={this.props.tileShape}
11001102
/>
11011103
</div>,
11021104
]);

src/components/views/rooms/PinnedEventTile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { replaceableComponent } from "../../../utils/replaceableComponent";
2929
import MatrixClientContext from "../../../contexts/MatrixClientContext";
3030
import { getUserNameColorClass } from "../../../utils/FormattingUtils";
3131
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
32+
import { TileShape } from "./EventTile";
3233

3334
interface IProps {
3435
room: Room;
@@ -87,6 +88,7 @@ export default class PinnedEventTile extends React.Component<IProps> {
8788
className="mx_PinnedEventTile_body"
8889
maxImageHeight={150}
8990
onHeightChanged={() => {}} // we need to give this, apparently
91+
tileShape={TileShape.Pinned}
9092
/>
9193
</div>
9294

0 commit comments

Comments
 (0)