@@ -53,12 +53,14 @@ import { CommunityPrototypeStore, IRoomProfile } from "../../../stores/Community
53
53
import { replaceableComponent } from "../../../utils/replaceableComponent" ;
54
54
import { getUnsentMessages } from "../../structures/RoomStatusBar" ;
55
55
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState" ;
56
+ import { ResizeNotifier } from "../../../utils/ResizeNotifier" ;
56
57
57
58
interface IProps {
58
59
room : Room ;
59
60
showMessagePreview : boolean ;
60
61
isMinimized : boolean ;
61
62
tag : TagID ;
63
+ resizeNotifier : ResizeNotifier ;
62
64
}
63
65
64
66
type PartialDOMRect = Pick < DOMRect , "left" | "bottom" > ;
@@ -102,6 +104,9 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
102
104
} ;
103
105
this . notificationState = RoomNotificationStateStore . instance . getRoomState ( this . props . room ) ;
104
106
this . roomProps = EchoChamber . forRoom ( this . props . room ) ;
107
+ if ( this . props . resizeNotifier ) {
108
+ this . props . resizeNotifier . on ( "middlePanelResized" , this . onResize ) ;
109
+ }
105
110
}
106
111
107
112
private countUnsentEvents ( ) : number {
@@ -116,6 +121,12 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
116
121
this . forceUpdate ( ) ; // notification state changed - update
117
122
} ;
118
123
124
+ private onResize = ( ) => {
125
+ if ( this . showMessagePreview && ! this . state . messagePreview ) {
126
+ this . setState ( { messagePreview : this . generatePreview ( ) } ) ;
127
+ }
128
+ } ;
129
+
119
130
private onLocalEchoUpdated = ( ev : MatrixEvent , room : Room ) => {
120
131
if ( ! room ?. roomId === this . props . room . roomId ) return ;
121
132
this . setState ( { hasUnsentEvents : this . countUnsentEvents ( ) > 0 } ) ;
@@ -195,6 +206,9 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
195
206
) ;
196
207
this . props . room . off ( "Room.name" , this . onRoomNameUpdate ) ;
197
208
}
209
+ if ( this . props . resizeNotifier ) {
210
+ this . props . resizeNotifier . off ( "middlePanelResized" , this . onResize ) ;
211
+ }
198
212
ActiveRoomObserver . removeListener ( this . props . room . roomId , this . onActiveRoomUpdate ) ;
199
213
defaultDispatcher . unregister ( this . dispatcherRef ) ;
200
214
this . notificationState . off ( NOTIFICATION_STATE_UPDATE , this . onNotificationUpdate ) ;
0 commit comments