Replies have the same layout as messages

This commit is contained in:
Jorik Schellekens 2020-05-05 10:54:44 +01:00
parent 67249e1e9c
commit 027826c2e1
3 changed files with 30 additions and 21 deletions

View file

@ -63,9 +63,12 @@ $right-padding: 5px;
display: flex; display: flex;
align-items: center; align-items: center;
> .mx_BaseAvatar { // Need to use important to override the js provided height and width values.
height: 1rem; > .mx_BaseAvatar, .mx_BaseAvatar > * {
width: 1rem; height: $font-14px !important;
width: $font-14px !important;
font-size: $font-10px !important;
line-height: $font-14px !important;
} }
} }
@ -90,6 +93,10 @@ $right-padding: 5px;
.mx_EventTile_line > * { .mx_EventTile_line > * {
display: inline-block; display: inline-block;
} }
.mx_EventTile_reply {
order: 3;
}
} }
.mx_EventListSummary { .mx_EventListSummary {

View file

@ -37,6 +37,8 @@ export default class ReplyThread extends React.Component {
// called when the ReplyThread contents has changed, including EventTiles thereof // called when the ReplyThread contents has changed, including EventTiles thereof
onHeightChanged: PropTypes.func.isRequired, onHeightChanged: PropTypes.func.isRequired,
permalinkCreator: PropTypes.instanceOf(RoomPermalinkCreator).isRequired, permalinkCreator: PropTypes.instanceOf(RoomPermalinkCreator).isRequired,
// Specifies which layout to use.
useIRCLayout: PropTypes.bool,
}; };
static contextType = MatrixClientContext; static contextType = MatrixClientContext;
@ -176,12 +178,12 @@ export default class ReplyThread extends React.Component {
}; };
} }
static makeThread(parentEv, onHeightChanged, permalinkCreator, ref) { static makeThread(parentEv, onHeightChanged, permalinkCreator, ref, useIRCLayout) {
if (!ReplyThread.getParentEventId(parentEv)) { if (!ReplyThread.getParentEventId(parentEv)) {
return <div />; return <div />;
} }
return <ReplyThread parentEv={parentEv} onHeightChanged={onHeightChanged} return <ReplyThread parentEv={parentEv} onHeightChanged={onHeightChanged}
ref={ref} permalinkCreator={permalinkCreator} />; ref={ref} permalinkCreator={permalinkCreator} useIRCLayout={useIRCLayout} />;
} }
componentDidMount() { componentDidMount() {
@ -331,7 +333,8 @@ export default class ReplyThread extends React.Component {
onHeightChanged={this.props.onHeightChanged} onHeightChanged={this.props.onHeightChanged}
permalinkCreator={this.props.permalinkCreator} permalinkCreator={this.props.permalinkCreator}
isRedacted={ev.isRedacted()} isRedacted={ev.isRedacted()}
isTwelveHour={SettingsStore.getValue("showTwelveHourTimestamps")} /> isTwelveHour={SettingsStore.getValue("showTwelveHourTimestamps")}
useIRCLayout={this.props.useIRCLayout} />
</blockquote>; </blockquote>;
}); });

View file

@ -795,6 +795,17 @@ export default createReactClass({
/>; />;
} }
const linkedTimestamp = <a
href={permalink}
onClick={this.onPermalinkClicked}
aria-label={formatTime(new Date(this.props.mxEvent.getTs()), this.props.isTwelveHour)}
>
{ timestamp }
</a>;
const groupTimestamp = !this.props.useIRCLayout ? linkedTimestamp : null;
const ircTimestamp = this.props.useIRCLayout ? linkedTimestamp : null;
switch (this.props.tileShape) { switch (this.props.tileShape) {
case 'notif': { case 'notif': {
const room = this.context.getRoom(this.props.mxEvent.getRoomId()); const room = this.context.getRoom(this.props.mxEvent.getRoomId());
@ -862,12 +873,11 @@ export default createReactClass({
} }
return ( return (
<div className={classes}> <div className={classes}>
{ ircTimestamp }
{ avatar } { avatar }
{ sender } { sender }
<div className="mx_EventTile_reply"> <div className="mx_EventTile_reply">
<a href={permalink} onClick={this.onPermalinkClicked}> { groupTimestamp }
{ timestamp }
</a>
{ !isBubbleMessage && this._renderE2EPadlock() } { !isBubbleMessage && this._renderE2EPadlock() }
{ thread } { thread }
<EventTileType ref={this._tile} <EventTileType ref={this._tile}
@ -886,20 +896,9 @@ export default createReactClass({
this.props.onHeightChanged, this.props.onHeightChanged,
this.props.permalinkCreator, this.props.permalinkCreator,
this._replyThread, this._replyThread,
this.props.useIRCLayout,
); );
const linkedTimestamp = <a
href={permalink}
onClick={this.onPermalinkClicked}
aria-label={formatTime(new Date(this.props.mxEvent.getTs()), this.props.isTwelveHour)}
>
{ timestamp }
</a>;
const groupTimestamp = !this.props.useIRCLayout ? linkedTimestamp : null;
const ircTimestamp = this.props.useIRCLayout ? linkedTimestamp : null;
// tab-index=-1 to allow it to be focusable but do not add tab stop for it, primarily for screen readers // tab-index=-1 to allow it to be focusable but do not add tab stop for it, primarily for screen readers
return ( return (
<div className={classes} tabIndex={-1}> <div className={classes} tabIndex={-1}>