@@ -22,6 +22,8 @@ import classNames from 'classnames';
22
22
import { ISyncStateData , SyncState } from 'matrix-js-sdk/src/sync' ;
23
23
import { IUsageLimit } from 'matrix-js-sdk/src/@types/partials' ;
24
24
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state" ;
25
+ import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests" ;
26
+ import { IContent } from "matrix-js-sdk/src/models/event" ;
25
27
26
28
import { isOnlyCtrlOrCmdKeyEvent , Key } from '../../Keyboard' ;
27
29
import PageTypes from '../../PageTypes' ;
@@ -71,6 +73,8 @@ import { SwitchSpacePayload } from "../../dispatcher/payloads/SwitchSpacePayload
71
73
import LegacyGroupView from "./LegacyGroupView" ;
72
74
import { IConfigOptions } from "../../IConfigOptions" ;
73
75
import LeftPanelLiveShareWarning from '../views/beacon/LeftPanelLiveShareWarning' ;
76
+ import { startDm } from '../../utils/direct-messages' ;
77
+ import { LocalRoom } from '../../models/LocalRoom' ;
74
78
75
79
// We need to fetch each pinned message individually (if we don't already have it)
76
80
// so each pinned message may trigger a request. Limit the number per room for sanity.
@@ -619,8 +623,27 @@ class LoggedInView extends React.Component<IProps, IState> {
619
623
620
624
render ( ) {
621
625
let pageElement ;
626
+ let messageComposerHandlers ;
622
627
623
628
switch ( this . props . page_type ) {
629
+ case PageTypes . LocalRoomView :
630
+ messageComposerHandlers = {
631
+ sendMessage : async (
632
+ localRoomId : string ,
633
+ threadId : string | null ,
634
+ content : IContent ,
635
+ ) : Promise < ISendEventResponse > => {
636
+ const room = this . _matrixClient . store . getRoom ( localRoomId ) ;
637
+
638
+ if ( ! ( room instanceof LocalRoom ) ) {
639
+ return ;
640
+ }
641
+
642
+ const rooomId = await startDm ( this . _matrixClient , room . targets ) ;
643
+ return this . _matrixClient . sendMessage ( rooomId , threadId , content ) ;
644
+ } ,
645
+ } ;
646
+ // fallthrough
624
647
case PageTypes . RoomView :
625
648
pageElement = < RoomView
626
649
ref = { this . _roomView }
@@ -631,6 +654,7 @@ class LoggedInView extends React.Component<IProps, IState> {
631
654
resizeNotifier = { this . props . resizeNotifier }
632
655
justCreatedOpts = { this . props . roomJustCreatedOpts }
633
656
forceTimeline = { this . props . forceTimeline }
657
+ messageComposerHandlers = { messageComposerHandlers }
634
658
/> ;
635
659
break ;
636
660
0 commit comments