Merge branch 'develop' into gsouquet/fix-thread-root-hidden

This commit is contained in:
Germain Souquet 2021-10-15 14:45:11 +01:00
commit 904147b194
13 changed files with 144 additions and 54 deletions

View file

@ -676,10 +676,57 @@ $hover-select-border: 4px;
} }
} }
.mx_ThreadInfo:hover { .mx_ThreadInfo {
cursor: pointer; height: 35px;
position: relative;
background-color: $system;
padding-left: 12px;
display: flex;
align-items: center;
border-radius: 8px;
padding-right: 16px;
padding-top: 8px;
padding-bottom: 8px;
font-size: 12px;
color: $secondary-content;
box-sizing: border-box;
justify-content: flex-start;
&:hover, &-active {
cursor: pointer;
border: 1px solid $quinary-content;
padding-top: 7px;
padding-bottom: 7px;
padding-left: 11px;
padding-right: 15px;
}
.mx_ThreadInfo_content {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
padding-left: 8px;
}
.mx_ThreadInfo_thread-icon {
mask-image: url('$(res)/img/element-icons/thread-summary.svg');
mask-position: center;
height: 16px;
min-width: 16px;
background-color: $secondary-content;
mask-repeat: no-repeat;
mask-size: contain;
}
.mx_ThreadInfo_threads-amount {
font-weight: 600;
position: relative;
padding: 0 8px;
white-space: nowrap;
}
} }
.mx_ThreadView { .mx_ThreadView {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View file

@ -15,7 +15,6 @@ limitations under the License.
*/ */
.mx_DevicesPanel { .mx_DevicesPanel {
display: table;
table-layout: fixed; table-layout: fixed;
// Normally the panel is 880px, however this can easily overflow the container. // Normally the panel is 880px, however this can easily overflow the container.
// TODO: Fix the table to not be squishy // TODO: Fix the table to not be squishy
@ -25,16 +24,17 @@ limitations under the License.
} }
.mx_DevicesPanel_header { .mx_DevicesPanel_header {
display: table-header-group;
font-weight: bold; font-weight: bold;
} }
.mx_DevicesPanel_header > .mx_DevicesPanel_deviceButtons { .mx_DevicesPanel_header .mx_DevicesPanel_deviceButtons {
height: 48px; // make this tall so the table doesn't move down when the delete button appears height: 48px; // make this tall so the table doesn't move down when the delete button appears
width: 20%;
} }
.mx_DevicesPanel_header > div { .mx_DevicesPanel_header th {
display: table-cell; padding: 0px;
text-align: left;
vertical-align: middle; vertical-align: middle;
} }
@ -46,16 +46,9 @@ limitations under the License.
width: 30%; width: 30%;
} }
.mx_DevicesPanel_header .mx_DevicesPanel_deviceButtons { .mx_DevicesPanel_device td {
width: 20%; vertical-align: baseline;
} padding: 0px;
.mx_DevicesPanel_device {
display: table-row;
}
.mx_DevicesPanel_device > div {
display: table-cell;
} }
.mx_DevicesPanel_myDevice { .mx_DevicesPanel_myDevice {

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none" viewBox="0 0 18 18"><path fill="#17191C" fill-rule="evenodd" d="M3 .25A2.75 2.75 0 0 0 .25 3v14a.75.75 0 0 0 1.2.6L4.916 15c.217-.162.48-.25.75-.25H15A2.75 2.75 0 0 0 17.75 12V3A2.75 2.75 0 0 0 15 .25H3ZM4.25 6A.75.75 0 0 1 5 5.25h8a.75.75 0 0 1 0 1.5H5A.75.75 0 0 1 4.25 6ZM5 8.25a.75.75 0 0 0 0 1.5h4a.75.75 0 1 0 0-1.5H5Z" clip-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 428 B

View file

@ -35,6 +35,7 @@ import Spinner from './Spinner';
import ReplyTile from "../rooms/ReplyTile"; import ReplyTile from "../rooms/ReplyTile";
import Pill from './Pill'; import Pill from './Pill';
import { Room } from 'matrix-js-sdk/src/models/room'; import { Room } from 'matrix-js-sdk/src/models/room';
import { RelationType } from 'matrix-js-sdk/src/@types/event';
/** /**
* This number is based on the previous behavior - if we have message of height * This number is based on the previous behavior - if we have message of height
@ -226,13 +227,30 @@ export default class ReplyThread extends React.Component<IProps, IState> {
public static makeReplyMixIn(ev: MatrixEvent) { public static makeReplyMixIn(ev: MatrixEvent) {
if (!ev) return {}; if (!ev) return {};
return {
const mixin: any = {
'm.relates_to': { 'm.relates_to': {
'm.in_reply_to': { 'm.in_reply_to': {
'event_id': ev.getId(), 'event_id': ev.getId(),
}, },
}, },
}; };
/**
* If the event replied is part of a thread
* Add the `m.thread` relation so that clients
* that know how to handle that relation will
* be able to render them more accurately
*/
if (ev.isThreadRelation) {
mixin['m.relates_to'] = {
...mixin['m.relates_to'],
rel_type: RelationType.Thread,
event_id: ev.threadRootId,
};
}
return mixin;
} }
public static hasThreadReply(event: MatrixEvent) { public static hasThreadReply(event: MatrixEvent) {

View file

@ -20,7 +20,7 @@ import React from "react";
import { RovingAccessibleTooltipButton } from "../../../accessibility/RovingTabIndex"; import { RovingAccessibleTooltipButton } from "../../../accessibility/RovingTabIndex";
import Spinner from "../elements/Spinner"; import Spinner from "../elements/Spinner";
import classNames from "classnames"; import classNames from "classnames";
import { _t } from "../../../languageHandler"; import { _t, _td } from "../../../languageHandler";
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import { FileDownloader } from "../../../utils/FileDownloader"; import { FileDownloader } from "../../../utils/FileDownloader";
@ -36,6 +36,7 @@ interface IProps {
interface IState { interface IState {
loading: boolean; loading: boolean;
blob?: Blob; blob?: Blob;
tooltip: string;
} }
@replaceableComponent("views.messages.DownloadActionButton") @replaceableComponent("views.messages.DownloadActionButton")
@ -47,12 +48,17 @@ export default class DownloadActionButton extends React.PureComponent<IProps, IS
this.state = { this.state = {
loading: false, loading: false,
tooltip: _td("Downloading"),
}; };
} }
private onDownloadClick = async () => { private onDownloadClick = async () => {
if (this.state.loading) return; if (this.state.loading) return;
if (this.props.mediaEventHelperGet().media.isEncrypted) {
this.setState({ tooltip: _td("Decrypting") });
}
this.setState({ loading: true }); this.setState({ loading: true });
if (this.state.blob) { if (this.state.blob) {
@ -87,7 +93,7 @@ export default class DownloadActionButton extends React.PureComponent<IProps, IS
return <RovingAccessibleTooltipButton return <RovingAccessibleTooltipButton
className={classes} className={classes}
title={spinner ? _t("Decrypting") : _t("Download")} title={spinner ? _t(this.state.tooltip) : _t("Download")}
onClick={this.onDownloadClick} onClick={this.onDownloadClick}
disabled={!!spinner} disabled={!!spinner}
> >

View file

@ -59,6 +59,7 @@ import { getEventDisplayInfo } from '../../../utils/EventUtils';
import SettingsStore from "../../../settings/SettingsStore"; import SettingsStore from "../../../settings/SettingsStore";
import MKeyVerificationConclusion from "../messages/MKeyVerificationConclusion"; import MKeyVerificationConclusion from "../messages/MKeyVerificationConclusion";
import { dispatchShowThreadEvent } from '../../../dispatcher/dispatch-actions/threads'; import { dispatchShowThreadEvent } from '../../../dispatcher/dispatch-actions/threads';
import { MessagePreviewStore } from '../../../stores/room-list/MessagePreviewStore';
const eventTileTypes = { const eventTileTypes = {
[EventType.RoomMessage]: 'messages.MessageEvent', [EventType.RoomMessage]: 'messages.MessageEvent',
@ -556,10 +557,9 @@ export default class EventTile extends React.Component<IProps, IState> {
return null; return null;
} }
const avatars = Array.from(thread.participants).map((mxId: string) => { const threadMessagePreview = MessagePreviewStore.instance.generateThreadPreview(this.state.thread);
const member = room.getMember(mxId);
return <MemberAvatar key={member.userId} member={member} width={14} height={14} />; if (!threadMessagePreview) return null;
});
return ( return (
<div <div
@ -568,10 +568,18 @@ export default class EventTile extends React.Component<IProps, IState> {
dispatchShowThreadEvent(this.props.mxEvent); dispatchShowThreadEvent(this.props.mxEvent);
}} }}
> >
<span className="mx_EventListSummary_avatars"> <span className="mx_ThreadInfo_thread-icon" />
{ avatars } <span className="mx_ThreadInfo_threads-amount">
{ _t("%(count)s reply", {
count: thread.length - 1,
}) }
</span> </span>
{ thread.length - 1 } { thread.length === 2 ? 'reply' : 'replies' } <MemberAvatar member={thread.replyToEvent.sender} width={24} height={24} />
<div className="mx_ThreadInfo_content">
<span className="mx_ThreadInfo_message-preview">
{ threadMessagePreview }
</span>
</div>
</div> </div>
); );
} }

View file

@ -218,17 +218,21 @@ export default class DevicesPanel extends React.Component<IProps, IState> {
const classes = classNames(this.props.className, "mx_DevicesPanel"); const classes = classNames(this.props.className, "mx_DevicesPanel");
return ( return (
<div className={classes}> <table className={classes}>
<div className="mx_DevicesPanel_header"> <thead className="mx_DevicesPanel_header">
<div className="mx_DevicesPanel_deviceId">{ _t("ID") }</div> <tr>
<div className="mx_DevicesPanel_deviceName">{ _t("Public Name") }</div> <th className="mx_DevicesPanel_deviceId">{ _t("ID") }</th>
<div className="mx_DevicesPanel_deviceLastSeen">{ _t("Last seen") }</div> <th className="mx_DevicesPanel_deviceName">{ _t("Public Name") }</th>
<div className="mx_DevicesPanel_deviceButtons"> <th className="mx_DevicesPanel_deviceLastSeen">{ _t("Last seen") }</th>
{ this.state.selectedDevices.length > 0 ? deleteButton : null } <th className="mx_DevicesPanel_deviceButtons">
</div> { this.state.selectedDevices.length > 0 ? deleteButton : null }
</div> </th>
{ devices.map(this.renderDevice) } </tr>
</div> </thead>
<tbody>
{ devices.map(this.renderDevice) }
</tbody>
</table>
); );
} }
} }

View file

@ -66,23 +66,23 @@ export default class DevicesPanelEntry extends React.Component<IProps> {
} }
return ( return (
<div className={"mx_DevicesPanel_device" + myDeviceClass}> <tr className={"mx_DevicesPanel_device" + myDeviceClass}>
<div className="mx_DevicesPanel_deviceId"> <td className="mx_DevicesPanel_deviceId">
{ device.device_id } { device.device_id }
</div> </td>
<div className="mx_DevicesPanel_deviceName"> <td className="mx_DevicesPanel_deviceName">
<EditableTextContainer initialValue={device.display_name} <EditableTextContainer initialValue={device.display_name}
onSubmit={this.onDisplayNameChanged} onSubmit={this.onDisplayNameChanged}
placeholder={device.device_id} placeholder={device.device_id}
/> />
</div> </td>
<div className="mx_DevicesPanel_lastSeen"> <td className="mx_DevicesPanel_lastSeen">
{ lastSeen } { lastSeen }
</div> </td>
<div className="mx_DevicesPanel_deviceButtons"> <td className="mx_DevicesPanel_deviceButtons">
<StyledCheckbox onChange={this.onDeviceToggled} checked={this.props.selected} /> <StyledCheckbox onChange={this.onDeviceToggled} checked={this.props.selected} />
</div> </td>
</div> </tr>
); );
} }
} }

View file

@ -1551,6 +1551,8 @@
"Send as message": "Send as message", "Send as message": "Send as message",
"Edit message": "Edit message", "Edit message": "Edit message",
"Mod": "Mod", "Mod": "Mod",
"%(count)s reply|other": "%(count)s replies",
"%(count)s reply|one": "%(count)s reply",
"This event could not be displayed": "This event could not be displayed", "This event could not be displayed": "This event could not be displayed",
"Your key share request has been sent - please check your other sessions for key share requests.": "Your key share request has been sent - please check your other sessions for key share requests.", "Your key share request has been sent - please check your other sessions for key share requests.": "Your key share request has been sent - please check your other sessions for key share requests.",
"Key share requests are sent to your other sessions automatically. If you rejected or dismissed the key share request on your other sessions, click here to request the keys for this session again.": "Key share requests are sent to your other sessions automatically. If you rejected or dismissed the key share request on your other sessions, click here to request the keys for this session again.", "Key share requests are sent to your other sessions automatically. If you rejected or dismissed the key share request on your other sessions, click here to request the keys for this session again.": "Key share requests are sent to your other sessions automatically. If you rejected or dismissed the key share request on your other sessions, click here to request the keys for this session again.",
@ -1959,6 +1961,7 @@
"Saturday": "Saturday", "Saturday": "Saturday",
"Today": "Today", "Today": "Today",
"Yesterday": "Yesterday", "Yesterday": "Yesterday",
"Downloading": "Downloading",
"Decrypting": "Decrypting", "Decrypting": "Decrypting",
"Download": "Download", "Download": "Download",
"View Source": "View Source", "View Source": "View Source",

View file

@ -27,6 +27,7 @@ import { CallHangupEvent } from "./previews/CallHangupEvent";
import { StickerEventPreview } from "./previews/StickerEventPreview"; import { StickerEventPreview } from "./previews/StickerEventPreview";
import { ReactionEventPreview } from "./previews/ReactionEventPreview"; import { ReactionEventPreview } from "./previews/ReactionEventPreview";
import { UPDATE_EVENT } from "../AsyncStore"; import { UPDATE_EVENT } from "../AsyncStore";
import { Thread } from "matrix-js-sdk/src/models/thread";
// Emitted event for when a room's preview has changed. First argument will the room for which // Emitted event for when a room's preview has changed. First argument will the room for which
// the change happened. // the change happened.
@ -108,6 +109,15 @@ export class MessagePreviewStore extends AsyncStoreWithClient<IState> {
return previews.get(inTagId); return previews.get(inTagId);
} }
public generateThreadPreview(thread: Thread): string {
const lastEvent = thread.replyToEvent;
const previewDef = PREVIEWS[lastEvent.getType()];
// TODO: Handle case where we don't have
if (!previewDef) return '';
const previewText = previewDef.previewer.getTextFor(lastEvent, null, true);
return previewText ?? '';
}
private async generatePreview(room: Room, tagId?: TagID) { private async generatePreview(room: Room, tagId?: TagID) {
const events = room.timeline; const events = room.timeline;
if (!events) return; // should only happen in tests if (!events) return; // should only happen in tests

View file

@ -23,7 +23,7 @@ import ReplyThread from "../../../components/views/elements/ReplyThread";
import { getHtmlText } from "../../../HtmlUtils"; import { getHtmlText } from "../../../HtmlUtils";
export class MessageEventPreview implements IPreview { export class MessageEventPreview implements IPreview {
public getTextFor(event: MatrixEvent, tagId?: TagID): string { public getTextFor(event: MatrixEvent, tagId?: TagID, isThread?: boolean): string {
let eventContent = event.getContent(); let eventContent = event.getContent();
if (event.isRelation("m.replace")) { if (event.isRelation("m.replace")) {
@ -64,7 +64,7 @@ export class MessageEventPreview implements IPreview {
return _t("* %(senderName)s %(emote)s", { senderName: getSenderName(event), emote: body }); return _t("* %(senderName)s %(emote)s", { senderName: getSenderName(event), emote: body });
} }
if (isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) { if (isThread || isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) {
return body; return body;
} else { } else {
return _t("%(senderName)s: %(message)s", { senderName: getSenderName(event), message: body }); return _t("%(senderName)s: %(message)s", { senderName: getSenderName(event), message: body });

View file

@ -23,7 +23,7 @@ import SettingsStore from "../../../settings/SettingsStore";
import DMRoomMap from "../../../utils/DMRoomMap"; import DMRoomMap from "../../../utils/DMRoomMap";
export class ReactionEventPreview implements IPreview { export class ReactionEventPreview implements IPreview {
public getTextFor(event: MatrixEvent, tagId?: TagID): string { public getTextFor(event: MatrixEvent, tagId?: TagID, isThread?: boolean): string {
const showDms = SettingsStore.getValue("feature_roomlist_preview_reactions_dms"); const showDms = SettingsStore.getValue("feature_roomlist_preview_reactions_dms");
const showAll = SettingsStore.getValue("feature_roomlist_preview_reactions_all"); const showAll = SettingsStore.getValue("feature_roomlist_preview_reactions_all");
@ -41,7 +41,7 @@ export class ReactionEventPreview implements IPreview {
const reaction = relation.key; const reaction = relation.key;
if (!reaction) return null; // invalid reaction (unknown format) if (!reaction) return null; // invalid reaction (unknown format)
if (isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) { if (isThread || isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) {
return reaction; return reaction;
} else { } else {
return _t("%(senderName)s: %(reaction)s", { senderName: getSenderName(event), reaction }); return _t("%(senderName)s: %(reaction)s", { senderName: getSenderName(event), reaction });

View file

@ -21,11 +21,11 @@ import { getSenderName, isSelf, shouldPrefixMessagesIn } from "./utils";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
export class StickerEventPreview implements IPreview { export class StickerEventPreview implements IPreview {
public getTextFor(event: MatrixEvent, tagId?: TagID): string { public getTextFor(event: MatrixEvent, tagId?: TagID, isThread?: boolean): string {
const stickerName = event.getContent()['body']; const stickerName = event.getContent()['body'];
if (!stickerName) return null; if (!stickerName) return null;
if (isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) { if (isThread || isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) {
return stickerName; return stickerName;
} else { } else {
return _t("%(senderName)s: %(stickerName)s", { senderName: getSenderName(event), stickerName }); return _t("%(senderName)s: %(stickerName)s", { senderName: getSenderName(event), stickerName });