diff --git a/src/ContentMessages.tsx b/src/ContentMessages.tsx index 7455d76c59..16804ae82d 100644 --- a/src/ContentMessages.tsx +++ b/src/ContentMessages.tsx @@ -20,7 +20,7 @@ import React from "react"; import { MatrixClient } from "matrix-js-sdk/src/client"; import { IEncryptedFile, IMediaEventInfo } from "./customisations/models/IMediaEventContent"; 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 * as sdk from './index'; @@ -518,6 +518,7 @@ export default class ContentMessages { uploadAll = true; } } + promBefore = this.sendContentToRoom(file, roomId, relation, matrixClient, promBefore); } } @@ -649,7 +650,10 @@ export default class ContentMessages { return promBefore; }).then(function() { 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")) { prom.then(resp => { sendRoundTripMetric(matrixClient, roomId, resp.event_id); diff --git a/src/components/structures/ThreadView.tsx b/src/components/structures/ThreadView.tsx index 615f3eed2a..758bf912a6 100644 --- a/src/components/structures/ThreadView.tsx +++ b/src/components/structures/ThreadView.tsx @@ -81,7 +81,7 @@ export default class ThreadView extends React.Component { this.teardownThread(); dis.unregister(this.dispatcherRef); const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); - room.on(ThreadEvent.New, this.onNewThread); + room.removeListener(ThreadEvent.New, this.onNewThread); } public componentDidUpdate(prevProps) { diff --git a/src/components/views/rooms/EditMessageComposer.tsx b/src/components/views/rooms/EditMessageComposer.tsx index 51df3fbebb..9b0b4868dc 100644 --- a/src/components/views/rooms/EditMessageComposer.tsx +++ b/src/components/views/rooms/EditMessageComposer.tsx @@ -426,7 +426,11 @@ class EditMessageComposer extends React.Component