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

Further improve replies #6396

Merged
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fa03943
Give reply tile an avatar
SimonBrandner Jul 17, 2021
1173e42
Improve `in reply to`
SimonBrandner Jul 17, 2021
1823d30
Drop `In reply to` for `Expand thread`
SimonBrandner Jul 18, 2021
f5947d8
Fix avatar alignment
SimonBrandner Jul 18, 2021
e4dc7cc
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Jul 18, 2021
48ecd17
Fix default avatar alignment
SimonBrandner Jul 18, 2021
115ef89
Simplifie code
SimonBrandner Jul 19, 2021
447ffc0
Simplifie some more code
SimonBrandner Jul 19, 2021
8e75c18
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Jul 22, 2021
ce5d973
Make replies lighter
SimonBrandner Jul 23, 2021
527ad32
Give replies a hover effect
SimonBrandner Jul 23, 2021
2344ed8
Revert changes to sender profile in replies
SimonBrandner Jul 23, 2021
2ce9b88
me Merge remote-tracking branch 'upstream/develop' into feature/impro…
SimonBrandner Jul 23, 2021
f2d0a9a
Improve padding
SimonBrandner Jul 26, 2021
714febf
Merge branch 'develop' into feature/improved-replies
robintown Jul 28, 2021
286b851
Increase line height of replies
robintown Jul 28, 2021
6c5b0c3
Replace reply hover effect with a color change
robintown Jul 28, 2021
47b03dd
Replace expand thread hover effect with an opacity change
robintown Jul 28, 2021
2862e0e
Simplify image and sticker reply designs
robintown Jul 29, 2021
e5293c3
Revise file and deleted message padding to match new reply layout
robintown Jul 29, 2021
afd9600
Remove unneeded CSS
robintown Jul 29, 2021
16a7943
Hide edited indicator from replies
robintown Jul 29, 2021
3bb7aff
Fix i18n
robintown Jul 29, 2021
3fdd70a
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Aug 18, 2021
6eca8b6
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Aug 25, 2021
e053588
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Oct 16, 2021
9cd4187
"Expand thread" -> "Expand replies"
SimonBrandner Oct 16, 2021
2ae66ef
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Oct 18, 2021
7f5f6a8
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Nov 15, 2021
3825fbe
Add a missing import
SimonBrandner Nov 15, 2021
0f8ed1e
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Nov 26, 2021
9752409
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Dec 10, 2021
efda6a2
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Jan 16, 2022
72eb401
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Jan 19, 2022
7e2ed72
Remove unused import
SimonBrandner Jan 19, 2022
3fdd38e
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Mar 3, 2022
57ba2c4
Remove unused import
SimonBrandner Mar 3, 2022
1dc8b90
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Mar 26, 2022
14f7f52
Use `this.state`
SimonBrandner Mar 26, 2022
9a5e71c
Fix sender profile confusion
SimonBrandner Mar 26, 2022
78ae7e8
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Apr 6, 2022
6c16a41
Merge branch 'develop' into feature/improved-replies
SimonBrandner May 1, 2022
8875f0b
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner May 7, 2022
c2cf242
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Jun 19, 2022
33a4ba2
Merge remote-tracking branch 'upstream/develop' into feature/improved…
SimonBrandner Oct 4, 2022
927c4d0
Merge branch 'develop' into feature/improved-replies
robintown Nov 17, 2022
e6197d8
Implement suggested changes
robintown Nov 17, 2022
ae6cdbf
Merge branch 'develop' into feature/improved-replies
robintown Nov 28, 2022
0689050
Make "In reply to" the same color as reply previews
robintown Nov 28, 2022
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
34 changes: 17 additions & 17 deletions res/css/views/elements/_ReplyChain.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,50 @@ limitations under the License.

.mx_ReplyChain {
margin: 0 0 $spacing-8 0;
padding: 0 10px; /* TODO: Use a spacing variable */
border-left: 2px solid $accent;
border-radius: 2px;
padding-left: 10px; // TODO: Use a spacing variable
border-left: 2px solid var(--username-color); // TODO: Use a spacing variable
border-radius: 2px; // TODO: Use a spacing variable

.mx_ReplyChain_show {
&.mx_AccessibleButton_kind_link_inline {
color: unset;
white-space: nowrap; /* Enforce 'In reply to' to be a single line */
@mixin ButtonResetDefault;

&:hover {
color: $links;
}
cursor: pointer;
color: var(--username-color);

&:hover {
opacity: 0.65;
}
}

&.mx_ReplyChain_color1 {
border-left-color: $username-variant1-color;
--username-color: $username-variant1-color;
}

&.mx_ReplyChain_color2 {
border-left-color: $username-variant2-color;
--username-color: $username-variant2-color;
}

&.mx_ReplyChain_color3 {
border-left-color: $username-variant3-color;
--username-color: $username-variant3-color;
}

&.mx_ReplyChain_color4 {
border-left-color: $username-variant4-color;
--username-color: $username-variant4-color;
}

&.mx_ReplyChain_color5 {
border-left-color: $username-variant5-color;
--username-color: $username-variant5-color;
}

&.mx_ReplyChain_color6 {
border-left-color: $username-variant6-color;
--username-color: $username-variant6-color;
}

&.mx_ReplyChain_color7 {
border-left-color: $username-variant7-color;
--username-color: $username-variant7-color;
}

&.mx_ReplyChain_color8 {
border-left-color: $username-variant8-color;
--username-color: $username-variant8-color;
}
}
51 changes: 35 additions & 16 deletions res/css/views/rooms/_ReplyTile.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ limitations under the License.
mask-image: url("$(res)/img/element-icons/call/video-call.svg");
}

.mx_MFileBody {
.mx_MFileBody_info {
margin: 5px 0;
}

.mx_MFileBody_download {
display: none;
}
}

> a {
display: flex;
flex-direction: column;
text-decoration: none;
color: $primary-content;
color: $tertiary-content;
gap: 4px;

&:hover {
color: $primary-content;
}
}

.mx_RedactedBody {
line-height: $font-18px;
}

.mx_RedactedBody,
Expand All @@ -52,13 +51,14 @@ limitations under the License.
&::before {
height: 13px;
width: 13px;
top: 5px;
top: 3px;
}
}

/* We do reply size limiting with CSS to avoid duplicating the TextualBody component. */
.mx_EventTile_content {
$reply-lines: 2;
$line-height: $font-18px;

text-overflow: ellipsis;
display: -webkit-box;
Expand All @@ -70,8 +70,8 @@ limitations under the License.
font-size: $font-14px !important; /* Override the big emoji override */
}

/* Hide line numbers */
.mx_EventTile_lineNumbers {
// Hide line numbers and edited indicator
.mx_EventTile_lineNumbers, .mx_EventTile_edited {
display: none;
}

Expand Down Expand Up @@ -101,7 +101,26 @@ limitations under the License.
padding-top: 0;
}

.mx_DisambiguatedProfile {
line-height: $font-17px;
.mx_ReplyTile_sender {
display: flex;
align-items: center;
gap: 4px;

.mx_DisambiguatedProfile {
font-size: $font-14px;

display: inline-block; // anti-zalgo, with overflow hidden
padding: 0;
margin: 0;

// truncate long display names
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.mx_BaseAvatar {
line-height: 14px; // To match size
}
}
}
50 changes: 13 additions & 37 deletions src/components/views/elements/ReplyChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import { MatrixClient } from 'matrix-js-sdk/src/client';

import { _t } from '../../../languageHandler';
import dis from '../../../dispatcher/dispatcher';
import { makeUserPermalink, RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
import SettingsStore from "../../../settings/SettingsStore";
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
import { Layout } from "../../../settings/enums/Layout";
import { getUserNameColorClass } from "../../../utils/FormattingUtils";
import { Action } from "../../../dispatcher/actions";
import Spinner from './Spinner';
import ReplyTile from "../rooms/ReplyTile";
import Pill, { PillType } from './Pill';
import AccessibleButton, { ButtonEvent } from './AccessibleButton';
import { ButtonEvent } from './AccessibleButton';
import { getParentEventId, shouldDisplayReply } from '../../../utils/Reply';
import RoomContext from "../../../contexts/RoomContext";
import { MatrixClientPeg } from '../../../MatrixClientPeg';
Expand Down Expand Up @@ -201,7 +199,7 @@ export default class ReplyChain extends React.Component<IProps, IState> {
return getUserNameColorClass(ev.getSender()).replace("Username", "ReplyChain");
}

render() {
public render(): JSX.Element {
let header = null;
if (this.state.err) {
header = <blockquote className="mx_ReplyChain mx_ReplyChain_error">
Expand All @@ -211,41 +209,19 @@ export default class ReplyChain extends React.Component<IProps, IState> {
}
</blockquote>;
} else if (this.state.loadedEv && shouldDisplayReply(this.state.events[0])) {
const ev = this.state.loadedEv;
const room = this.matrixClient.getRoom(ev.getRoomId());
header = <blockquote className={`mx_ReplyChain ${this.getReplyChainColorClass(ev)}`}>
{
_t('<a>In reply to</a> <pill>', {}, {
'a': (sub) => (
<AccessibleButton
kind="link_inline"
className="mx_ReplyChain_show"
onClick={this.onQuoteClick}
>
{ sub }
</AccessibleButton>
),
'pill': (
<Pill
type={PillType.UserMention}
room={room}
url={makeUserPermalink(ev.getSender())}
shouldShowPillAvatar={SettingsStore.getValue("Pill.shouldShowPillAvatar")}
/>
),
})
}
</blockquote>;
header = (
<blockquote className={`mx_ReplyChain ${this.getReplyChainColorClass(this.state.loadedEv)}`}>
<button className="mx_ReplyChain_show" onClick={this.onQuoteClick}>
{ _t("Expand replies") }
</button>
</blockquote>
);
} else if (this.props.forExport) {
const eventId = getParentEventId(this.props.parentEv);
header = <p className="mx_ReplyChain_Export">
{ _t("In reply to <a>this message</a>",
{},
{ a: (sub) => (
<a className="mx_reply_anchor" href={`#${eventId}`} scroll-to={eventId}> { sub } </a>
),
})
}
<a className="mx_reply_anchor" href={`#${eventId}`} scroll-to={eventId}>
{ _t("Expand replies") }
</a>
</p>;
} else if (this.state.loading) {
header = <Spinner w={16} h={16} />;
Expand Down
22 changes: 0 additions & 22 deletions src/components/views/messages/MImageReplyBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ limitations under the License.
*/

import React from "react";
import { EventType } from "matrix-js-sdk/src/@types/event";

import MImageBody from "./MImageBody";
import { presentableTextForFile } from "../../../utils/FileUtils";
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
import SenderProfile from "./SenderProfile";
import { _t } from "../../../languageHandler";

const FORCED_IMAGE_HEIGHT = 44;

Expand All @@ -34,34 +30,16 @@ export default class MImageReplyBody extends MImageBody {
return children;
}

// Don't show "Download this_file.png ..."
public getFileBody(): string {
const sticker = this.props.mxEvent.getType() === EventType.Sticker;
return presentableTextForFile(this.props.mxEvent.getContent(), sticker ? _t("Sticker") : _t("Image"), !sticker);
}

protected getBanner(content: IMediaEventContent): JSX.Element {
return null; // we don't need a banner, nor have space for one
}

render() {
if (this.state.error) {
return super.render();
}

const content = this.props.mxEvent.getContent<IMediaEventContent>();
const thumbnail = this.messageContent(this.state.contentUrl, this.state.thumbUrl, content, FORCED_IMAGE_HEIGHT);
const fileBody = this.getFileBody();
const sender = <SenderProfile
mxEvent={this.props.mxEvent}
/>;

return <div className="mx_MImageReplyBody">
{ thumbnail }
<div className="mx_MImageReplyBody_info">
<div className="mx_MImageReplyBody_sender">{ sender }</div>
<div className="mx_MImageReplyBody_filename">{ fileBody }</div>
</div>
</div>;
}
}
29 changes: 17 additions & 12 deletions src/components/views/rooms/ReplyTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import MImageReplyBody from "../messages/MImageReplyBody";
import { isVoiceMessage } from '../../../utils/EventUtils';
import { getEventDisplayInfo } from "../../../utils/EventRenderingUtils";
import MFileBody from "../messages/MFileBody";
import MemberAvatar from '../avatars/MemberAvatar';
import MVoiceMessageBody from "../messages/MVoiceMessageBody";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { renderReplyTile } from "../../../events/EventTileFactory";
Expand Down Expand Up @@ -108,7 +109,7 @@ export default class ReplyTile extends React.PureComponent<IProps> {
render() {
const mxEvent = this.props.mxEvent;
const msgType = mxEvent.getContent().msgtype;
const evType = mxEvent.getType() as EventType;
const evType = mxEvent.getType();

const {
hasRenderer, isInfoMessage, isSeeingThroughMessageHiddenForModeration,
Expand All @@ -135,17 +136,21 @@ export default class ReplyTile extends React.PureComponent<IProps> {
}

let sender;
const needsSenderProfile = (
!isInfoMessage
&& msgType !== MsgType.Image
&& evType !== EventType.Sticker
&& evType !== EventType.RoomCreate
);

if (needsSenderProfile) {
sender = <SenderProfile
mxEvent={mxEvent}
/>;
const hasOwnSender = isInfoMessage || evType === EventType.RoomCreate;
if (!hasOwnSender) {
sender = (
<div className="mx_ReplyTile_sender">
<MemberAvatar
member={mxEvent.sender}
fallbackUserId={mxEvent.getSender()}
width={14}
height={14}
/>
<SenderProfile
mxEvent={mxEvent}
/>
</div>
);
}

const msgtypeOverrides: Record<string, typeof React.Component> = {
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2459,8 +2459,7 @@
"Custom level": "Custom level",
"QR Code": "QR Code",
"Unable to load event that was replied to, it either does not exist or you do not have permission to view it.": "Unable to load event that was replied to, it either does not exist or you do not have permission to view it.",
"<a>In reply to</a> <pill>": "<a>In reply to</a> <pill>",
"In reply to <a>this message</a>": "In reply to <a>this message</a>",
"Expand replies": "Expand replies",
"Room address": "Room address",
"e.g. my-room": "e.g. my-room",
"Missing domain separator e.g. (:domain.org)": "Missing domain separator e.g. (:domain.org)",
Expand Down