@@ -35,7 +35,7 @@ import { getKeyBindingsManager, MessageComposerAction } from '../../../KeyBindin
3535import { replaceableComponent } from "../../../utils/replaceableComponent" ;
3636import SendHistoryManager from '../../../SendHistoryManager' ;
3737import Modal from '../../../Modal' ;
38- import { MsgType } from 'matrix-js-sdk/src/@types/event' ;
38+ import { MsgType , UNSTABLE_ELEMENT_REPLY_IN_THREAD } from 'matrix-js-sdk/src/@types/event' ;
3939import { Room } from 'matrix-js-sdk/src/models/room' ;
4040import ErrorDialog from "../dialogs/ErrorDialog" ;
4141import QuestionDialog from "../dialogs/QuestionDialog" ;
@@ -46,7 +46,7 @@ import SettingsStore from "../../../settings/SettingsStore";
4646
4747import { logger } from "matrix-js-sdk/src/logger" ;
4848import { withMatrixClientHOC , MatrixClientProps } from '../../../contexts/MatrixClientContext' ;
49- import RoomContext from '../../../contexts/RoomContext' ;
49+ import RoomContext , { TimelineRenderingType } from '../../../contexts/RoomContext' ;
5050
5151function getHtmlReplyFallback ( mxEvent : MatrixEvent ) : string {
5252 const html = mxEvent . getContent ( ) . formatted_body ;
@@ -67,7 +67,11 @@ function getTextReplyFallback(mxEvent: MatrixEvent): string {
6767 return "" ;
6868}
6969
70- function createEditContent ( model : EditorModel , editedEvent : MatrixEvent ) : IContent {
70+ function createEditContent (
71+ model : EditorModel ,
72+ editedEvent : MatrixEvent ,
73+ renderingContext ?: TimelineRenderingType ,
74+ ) : IContent {
7175 const isEmote = containsEmote ( model ) ;
7276 if ( isEmote ) {
7377 model = stripEmoteCommand ( model ) ;
@@ -100,13 +104,19 @@ function createEditContent(model: EditorModel, editedEvent: MatrixEvent): IConte
100104 contentBody . formatted_body = `${ htmlPrefix } * ${ formattedBody } ` ;
101105 }
102106
103- return Object . assign ( {
107+ const relation = {
104108 "m.new_content" : newContent ,
105109 "m.relates_to" : {
106110 "rel_type" : "m.replace" ,
107111 "event_id" : editedEvent . getId ( ) ,
108112 } ,
109- } , contentBody ) ;
113+ } ;
114+
115+ if ( renderingContext === TimelineRenderingType . Thread ) {
116+ relation [ 'm.relates_to' ] [ UNSTABLE_ELEMENT_REPLY_IN_THREAD . name ] = true ;
117+ }
118+
119+ return Object . assign ( relation , contentBody ) ;
110120}
111121
112122interface IEditMessageComposerProps extends MatrixClientProps {
@@ -132,8 +142,11 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
132142
133143 const isRestored = this . createEditorModel ( ) ;
134144 const ev = this . props . editState . getEvent ( ) ;
145+
146+ const renderingContext = this . context . timelineRenderingType ;
147+ const editContent = createEditContent ( this . model , ev , renderingContext ) ;
135148 this . state = {
136- saveDisabled : ! isRestored || ! this . isContentModified ( createEditContent ( this . model , ev ) [ "m.new_content" ] ) ,
149+ saveDisabled : ! isRestored || ! this . isContentModified ( editContent [ "m.new_content" ] ) ,
137150 } ;
138151
139152 window . addEventListener ( "beforeunload" , this . saveStoredEditorState ) ;
@@ -356,8 +369,8 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
356369 const position = this . model . positionForOffset ( caret . offset , caret . atNodeEnd ) ;
357370 this . editorRef . current ?. replaceEmoticon ( position , REGEX_EMOTICON ) ;
358371 }
359-
360- const editContent = createEditContent ( this . model , editedEvent ) ;
372+ const renderingContext = this . context . timelineRenderingType ;
373+ const editContent = createEditContent ( this . model , editedEvent , renderingContext ) ;
361374 const newContent = editContent [ "m.new_content" ] ;
362375
363376 let shouldSend = true ;
0 commit comments