@@ -35,7 +35,7 @@ import { getKeyBindingsManager, MessageComposerAction } from '../../../KeyBindin
35
35
import { replaceableComponent } from "../../../utils/replaceableComponent" ;
36
36
import SendHistoryManager from '../../../SendHistoryManager' ;
37
37
import 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' ;
39
39
import { Room } from 'matrix-js-sdk/src/models/room' ;
40
40
import ErrorDialog from "../dialogs/ErrorDialog" ;
41
41
import QuestionDialog from "../dialogs/QuestionDialog" ;
@@ -46,7 +46,7 @@ import SettingsStore from "../../../settings/SettingsStore";
46
46
47
47
import { logger } from "matrix-js-sdk/src/logger" ;
48
48
import { withMatrixClientHOC , MatrixClientProps } from '../../../contexts/MatrixClientContext' ;
49
- import RoomContext from '../../../contexts/RoomContext' ;
49
+ import RoomContext , { TimelineRenderingType } from '../../../contexts/RoomContext' ;
50
50
51
51
function getHtmlReplyFallback ( mxEvent : MatrixEvent ) : string {
52
52
const html = mxEvent . getContent ( ) . formatted_body ;
@@ -67,7 +67,11 @@ function getTextReplyFallback(mxEvent: MatrixEvent): string {
67
67
return "" ;
68
68
}
69
69
70
- function createEditContent ( model : EditorModel , editedEvent : MatrixEvent ) : IContent {
70
+ function createEditContent (
71
+ model : EditorModel ,
72
+ editedEvent : MatrixEvent ,
73
+ renderingContext ?: TimelineRenderingType ,
74
+ ) : IContent {
71
75
const isEmote = containsEmote ( model ) ;
72
76
if ( isEmote ) {
73
77
model = stripEmoteCommand ( model ) ;
@@ -100,13 +104,19 @@ function createEditContent(model: EditorModel, editedEvent: MatrixEvent): IConte
100
104
contentBody . formatted_body = `${ htmlPrefix } * ${ formattedBody } ` ;
101
105
}
102
106
103
- return Object . assign ( {
107
+ const relation = {
104
108
"m.new_content" : newContent ,
105
109
"m.relates_to" : {
106
110
"rel_type" : "m.replace" ,
107
111
"event_id" : editedEvent . getId ( ) ,
108
112
} ,
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 ) ;
110
120
}
111
121
112
122
interface IEditMessageComposerProps extends MatrixClientProps {
@@ -132,8 +142,11 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
132
142
133
143
const isRestored = this . createEditorModel ( ) ;
134
144
const ev = this . props . editState . getEvent ( ) ;
145
+
146
+ const renderingContext = this . context . timelineRenderingType ;
147
+ const editContent = createEditContent ( this . model , ev , renderingContext ) ;
135
148
this . state = {
136
- saveDisabled : ! isRestored || ! this . isContentModified ( createEditContent ( this . model , ev ) [ "m.new_content" ] ) ,
149
+ saveDisabled : ! isRestored || ! this . isContentModified ( editContent [ "m.new_content" ] ) ,
137
150
} ;
138
151
139
152
window . addEventListener ( "beforeunload" , this . saveStoredEditorState ) ;
@@ -356,8 +369,8 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
356
369
const position = this . model . positionForOffset ( caret . offset , caret . atNodeEnd ) ;
357
370
this . editorRef . current ?. replaceEmoticon ( position , REGEX_EMOTICON ) ;
358
371
}
359
-
360
- const editContent = createEditContent ( this . model , editedEvent ) ;
372
+ const renderingContext = this . context . timelineRenderingType ;
373
+ const editContent = createEditContent ( this . model , editedEvent , renderingContext ) ;
361
374
const newContent = editContent [ "m.new_content" ] ;
362
375
363
376
let shouldSend = true ;
0 commit comments