mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 09:46:09 +03:00
Make local echo work for threads (#7157)
This commit is contained in:
parent
7f350ae0f4
commit
392c4ad8d9
4 changed files with 17 additions and 5 deletions
|
@ -20,7 +20,7 @@ import React from "react";
|
||||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
import { IEncryptedFile, IMediaEventInfo } from "./customisations/models/IMediaEventContent";
|
import { IEncryptedFile, IMediaEventInfo } from "./customisations/models/IMediaEventContent";
|
||||||
import { IUploadOpts } from "matrix-js-sdk/src/@types/requests";
|
import { IUploadOpts } from "matrix-js-sdk/src/@types/requests";
|
||||||
import { MsgType } from "matrix-js-sdk/src/@types/event";
|
import { MsgType, RelationType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
|
||||||
import dis from './dispatcher/dispatcher';
|
import dis from './dispatcher/dispatcher';
|
||||||
import * as sdk from './index';
|
import * as sdk from './index';
|
||||||
|
@ -518,6 +518,7 @@ export default class ContentMessages {
|
||||||
uploadAll = true;
|
uploadAll = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
promBefore = this.sendContentToRoom(file, roomId, relation, matrixClient, promBefore);
|
promBefore = this.sendContentToRoom(file, roomId, relation, matrixClient, promBefore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,7 +650,10 @@ export default class ContentMessages {
|
||||||
return promBefore;
|
return promBefore;
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
if (upload.canceled) throw new UploadCanceledError();
|
if (upload.canceled) throw new UploadCanceledError();
|
||||||
const prom = matrixClient.sendMessage(roomId, content);
|
const threadId = relation?.rel_type === RelationType.Thread
|
||||||
|
? relation.event_id
|
||||||
|
: null;
|
||||||
|
const prom = matrixClient.sendMessage(roomId, threadId, content);
|
||||||
if (SettingsStore.getValue("Performance.addSendMessageTimingMetadata")) {
|
if (SettingsStore.getValue("Performance.addSendMessageTimingMetadata")) {
|
||||||
prom.then(resp => {
|
prom.then(resp => {
|
||||||
sendRoundTripMetric(matrixClient, roomId, resp.event_id);
|
sendRoundTripMetric(matrixClient, roomId, resp.event_id);
|
||||||
|
|
|
@ -81,7 +81,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
|
||||||
this.teardownThread();
|
this.teardownThread();
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
|
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
|
||||||
room.on(ThreadEvent.New, this.onNewThread);
|
room.removeListener(ThreadEvent.New, this.onNewThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidUpdate(prevProps) {
|
public componentDidUpdate(prevProps) {
|
||||||
|
|
|
@ -426,7 +426,11 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
|
||||||
}
|
}
|
||||||
if (shouldSend) {
|
if (shouldSend) {
|
||||||
this.cancelPreviousPendingEdit();
|
this.cancelPreviousPendingEdit();
|
||||||
const prom = this.props.mxClient.sendMessage(roomId, editContent);
|
|
||||||
|
const event = this.props.editState.getEvent();
|
||||||
|
const threadId = event.threadRootId || null;
|
||||||
|
|
||||||
|
const prom = this.props.mxClient.sendMessage(roomId, threadId, editContent);
|
||||||
this.clearStoredEditorState();
|
this.clearStoredEditorState();
|
||||||
dis.dispatch({ action: "message_sent" });
|
dis.dispatch({ action: "message_sent" });
|
||||||
CountlyAnalytics.instance.trackSendMessage(startTime, prom, roomId, true, false, editContent);
|
CountlyAnalytics.instance.trackSendMessage(startTime, prom, roomId, true, false, editContent);
|
||||||
|
|
|
@ -483,7 +483,11 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
||||||
decorateStartSendingTime(content);
|
decorateStartSendingTime(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
const prom = this.props.mxClient.sendMessage(roomId, content);
|
const threadId = this.props.relation?.rel_type === RelationType.Thread
|
||||||
|
? this.props.relation.event_id
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const prom = this.props.mxClient.sendMessage(roomId, threadId, content);
|
||||||
if (replyToEvent) {
|
if (replyToEvent) {
|
||||||
// Clear reply_to_event as we put the message into the queue
|
// Clear reply_to_event as we put the message into the queue
|
||||||
// if the send fails, retry will handle resending.
|
// if the send fails, retry will handle resending.
|
||||||
|
|
Loading…
Reference in a new issue