Skip to content

Commit b2cb944

Browse files
committed
Merge branch 'develop' into travis/voice-messages/interrupt-text
2 parents 91d0b55 + b8f6d29 commit b2cb944

File tree

15 files changed

+82
-31
lines changed

15 files changed

+82
-31
lines changed

res/themes/light/css/_light.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ $appearance-tab-border-color: $input-darker-bg-color;
354354

355355
// blur amounts for left left panel (only for element theme)
356356
:root {
357-
--lp-background-blur: 30px;
357+
--lp-background-blur: 40px;
358358
}
359359
$composer-shadow-color: rgba(0, 0, 0, 0.04);
360360

src/components/structures/SpaceRoomView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ const SpaceSetupFirstRooms = ({ space, title, description, onFinished }) => {
519519
inlineErrors: true,
520520
parentSpace: space,
521521
joinRule: !isPublic ? JoinRule.Restricted : undefined,
522+
suggested: true,
522523
});
523524
}));
524525
onFinished(filteredRoomNames.length > 0);

src/components/structures/ThreadView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
136136
<MessageComposer
137137
room={this.props.room}
138138
resizeNotifier={this.props.resizeNotifier}
139+
replyInThread={true}
139140
replyToEvent={this.state?.thread?.replyToEvent}
140141
showReplyPreview={false}
141142
permalinkCreator={this.props.permalinkCreator}

src/components/views/elements/ReplyThread.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import React from 'react';
1919
import { _t } from '../../../languageHandler';
2020
import dis from '../../../dispatcher/dispatcher';
2121
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
22+
import { UNSTABLE_ELEMENT_REPLY_IN_THREAD } from "matrix-js-sdk/src/@types/event";
2223
import { makeUserPermalink, RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
2324
import SettingsStore from "../../../settings/SettingsStore";
2425
import { Layout } from "../../../settings/Layout";
@@ -206,15 +207,28 @@ export default class ReplyThread extends React.Component<IProps, IState> {
206207
return { body, html };
207208
}
208209

209-
public static makeReplyMixIn(ev: MatrixEvent) {
210+
public static makeReplyMixIn(ev: MatrixEvent, replyInThread: boolean) {
210211
if (!ev) return {};
211-
return {
212+
213+
const replyMixin = {
212214
'm.relates_to': {
213215
'm.in_reply_to': {
214216
'event_id': ev.getId(),
215217
},
216218
},
217219
};
220+
221+
/**
222+
* @experimental
223+
* Rendering hint for threads, only attached if true to make
224+
* sure that Element does not start sending that property for all events
225+
*/
226+
if (replyInThread) {
227+
const inReplyTo = replyMixin['m.relates_to']['m.in_reply_to'];
228+
inReplyTo[UNSTABLE_ELEMENT_REPLY_IN_THREAD.name] = replyInThread;
229+
}
230+
231+
return replyMixin;
218232
}
219233

220234
public static makeThread(

src/components/views/messages/MImageBody.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
128128
private onImageEnter = (e: React.MouseEvent<HTMLImageElement>): void => {
129129
this.setState({ hover: true });
130130

131-
if (!this.state.showImage || !this.isGif() || SettingsStore.getValue("autoplayGifsAndVideos")) {
131+
if (!this.state.showImage || !this.isGif() || SettingsStore.getValue("autoplayGifs")) {
132132
return;
133133
}
134134
const imgElement = e.currentTarget;
@@ -138,7 +138,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
138138
private onImageLeave = (e: React.MouseEvent<HTMLImageElement>): void => {
139139
this.setState({ hover: false });
140140

141-
if (!this.state.showImage || !this.isGif() || SettingsStore.getValue("autoplayGifsAndVideos")) {
141+
if (!this.state.showImage || !this.isGif() || SettingsStore.getValue("autoplayGifs")) {
142142
return;
143143
}
144144
const imgElement = e.currentTarget;
@@ -387,7 +387,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
387387
showPlaceholder = false; // because we're hiding the image, so don't show the placeholder.
388388
}
389389

390-
if (this.isGif() && !SettingsStore.getValue("autoplayGifsAndVideos") && !this.state.hover) {
390+
if (this.isGif() && !SettingsStore.getValue("autoplayGifs") && !this.state.hover) {
391391
gifLabel = <p className="mx_MImageBody_gifLabel">GIF</p>;
392392
}
393393

@@ -487,7 +487,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
487487

488488
const contentUrl = this.getContentUrl();
489489
let thumbUrl;
490-
if (this.isGif() && SettingsStore.getValue("autoplayGifsAndVideos")) {
490+
if (this.isGif() && SettingsStore.getValue("autoplayGifs")) {
491491
thumbUrl = contentUrl;
492492
} else {
493493
thumbUrl = this.getThumbUrl();

src/components/views/messages/MVideoBody.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
145145
}
146146

147147
async componentDidMount() {
148-
const autoplay = SettingsStore.getValue("autoplayGifsAndVideos") as boolean;
148+
const autoplay = SettingsStore.getValue("autoplayVideo") as boolean;
149149
this.loadBlurhash();
150150

151151
if (this.props.mediaEventHelper.media.isEncrypted && this.state.decryptedUrl === null) {
@@ -209,7 +209,7 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
209209

210210
render() {
211211
const content = this.props.mxEvent.getContent();
212-
const autoplay = SettingsStore.getValue("autoplayGifsAndVideos");
212+
const autoplay = SettingsStore.getValue("autoplayVideo");
213213

214214
if (this.state.error !== null) {
215215
return (

src/components/views/rooms/EditMessageComposer.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ import QuestionDialog from "../dialogs/QuestionDialog";
4343
import { ActionPayload } from "../../../dispatcher/payloads";
4444
import AccessibleButton from '../elements/AccessibleButton';
4545

46-
function eventIsReply(mxEvent: MatrixEvent): boolean {
47-
const relatesTo = mxEvent.getContent()["m.relates_to"];
48-
return !!(relatesTo && relatesTo["m.in_reply_to"]);
49-
}
50-
5146
function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
5247
const html = mxEvent.getContent().formatted_body;
5348
if (!html) {
@@ -72,7 +67,7 @@ function createEditContent(model: EditorModel, editedEvent: MatrixEvent): IConte
7267
if (isEmote) {
7368
model = stripEmoteCommand(model);
7469
}
75-
const isReply = eventIsReply(editedEvent);
70+
const isReply = !!editedEvent.replyEventId;
7671
let plainPrefix = "";
7772
let htmlPrefix = "";
7873

src/components/views/rooms/MessageComposer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ interface IProps {
183183
resizeNotifier: ResizeNotifier;
184184
permalinkCreator: RoomPermalinkCreator;
185185
replyToEvent?: MatrixEvent;
186+
replyInThread?: boolean;
186187
showReplyPreview?: boolean;
187188
e2eStatus?: E2EStatus;
188189
compact?: boolean;
@@ -204,6 +205,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
204205
private voiceRecordingButton: VoiceRecordComposerTile;
205206

206207
static defaultProps = {
208+
replyInThread: false,
207209
showReplyPreview: true,
208210
compact: false,
209211
};
@@ -383,6 +385,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
383385
room={this.props.room}
384386
placeholder={this.renderPlaceholderText()}
385387
permalinkCreator={this.props.permalinkCreator}
388+
replyInThread={this.props.replyInThread}
386389
replyToEvent={this.props.replyToEvent}
387390
onChange={this.onChange}
388391
disabled={this.state.haveRecording}

src/components/views/rooms/SendMessageComposer.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ import { ActionPayload } from "../../../dispatcher/payloads";
5757

5858
function addReplyToMessageContent(
5959
content: IContent,
60-
repliedToEvent: MatrixEvent,
60+
replyToEvent: MatrixEvent,
61+
replyInThread: boolean,
6162
permalinkCreator: RoomPermalinkCreator,
6263
): void {
63-
const replyContent = ReplyThread.makeReplyMixIn(repliedToEvent);
64+
const replyContent = ReplyThread.makeReplyMixIn(replyToEvent, replyInThread);
6465
Object.assign(content, replyContent);
6566

6667
// Part of Replies fallback support - prepend the text we're sending
6768
// with the text we're replying to
68-
const nestedReply = ReplyThread.getNestedReplyText(repliedToEvent, permalinkCreator);
69+
const nestedReply = ReplyThread.getNestedReplyText(replyToEvent, permalinkCreator);
6970
if (nestedReply) {
7071
if (content.formatted_body) {
7172
content.formatted_body = nestedReply.html + content.formatted_body;
@@ -77,8 +78,9 @@ function addReplyToMessageContent(
7778
// exported for tests
7879
export function createMessageContent(
7980
model: EditorModel,
80-
permalinkCreator: RoomPermalinkCreator,
8181
replyToEvent: MatrixEvent,
82+
replyInThread: boolean,
83+
permalinkCreator: RoomPermalinkCreator,
8284
): IContent {
8385
const isEmote = containsEmote(model);
8486
if (isEmote) {
@@ -101,7 +103,7 @@ export function createMessageContent(
101103
}
102104

103105
if (replyToEvent) {
104-
addReplyToMessageContent(content, replyToEvent, permalinkCreator);
106+
addReplyToMessageContent(content, replyToEvent, replyInThread, permalinkCreator);
105107
}
106108

107109
return content;
@@ -129,6 +131,7 @@ interface IProps {
129131
room: Room;
130132
placeholder?: string;
131133
permalinkCreator: RoomPermalinkCreator;
134+
replyInThread?: boolean;
132135
replyToEvent?: MatrixEvent;
133136
disabled?: boolean;
134137
onChange?(model: EditorModel): void;
@@ -357,7 +360,12 @@ export default class SendMessageComposer extends React.Component<IProps> {
357360
if (cmd.category === CommandCategories.messages) {
358361
content = await this.runSlashCommand(cmd, args);
359362
if (replyToEvent) {
360-
addReplyToMessageContent(content, replyToEvent, this.props.permalinkCreator);
363+
addReplyToMessageContent(
364+
content,
365+
replyToEvent,
366+
this.props.replyInThread,
367+
this.props.permalinkCreator,
368+
);
361369
}
362370
} else {
363371
this.runSlashCommand(cmd, args);
@@ -400,7 +408,12 @@ export default class SendMessageComposer extends React.Component<IProps> {
400408
const startTime = CountlyAnalytics.getTimestamp();
401409
const { roomId } = this.props.room;
402410
if (!content) {
403-
content = createMessageContent(this.model, this.props.permalinkCreator, replyToEvent);
411+
content = createMessageContent(
412+
this.model,
413+
replyToEvent,
414+
this.props.replyInThread,
415+
this.props.permalinkCreator,
416+
);
404417
}
405418
// don't bother sending an empty message
406419
if (!content.body.trim()) return;

src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
172172
];
173173
static IMAGES_AND_VIDEOS_SETTINGS = [
174174
'urlPreviewsEnabled',
175-
'autoplayGifsAndVideos',
175+
'autoplayGifs',
176+
'autoplayVideo',
176177
'showImages',
177178
];
178179
static TIMELINE_SETTINGS = [

0 commit comments

Comments
 (0)