@@ -75,16 +75,13 @@ export class RoomUploadViewModel
7575 } ,
7676 ) ;
7777 // Initial check.
78- this . onRoomCurrentStateUpdated ( ) ;
78+ this . updateOptions ( ) ;
7979 // Configure upload functions
8080 for ( const option of moduleComposerApi . fileUploadOptions ) {
8181 this . uploadSelectFns . set ( option . type , option . onSelected ) ;
8282 }
8383 this . uploadSelectFns . set ( "local" , this . openUploadDialog ) ;
84- room . on ( RoomEvent . CurrentStateUpdated , this . onRoomCurrentStateUpdated ) ;
8584 this . disposables . trackListener ( room , RoomEvent . CurrentStateUpdated , this . onRoomCurrentStateUpdated ) ;
86-
87- moduleComposerApi . on ( ModuleComposerApiEvents . UploaderOptionsChanged , this . onUploaderOptionsChanged ) ;
8885 this . disposables . trackListener (
8986 moduleComposerApi ,
9087 ModuleComposerApiEvents . UploaderOptionsChanged ,
@@ -94,8 +91,12 @@ export class RoomUploadViewModel
9491 }
9592
9693 private onRoomCurrentStateUpdated = ( ) : void => {
94+ this . updateOptions ( ) ;
95+ } ;
96+
97+ private updateOptions ( ) : void {
9798 const maySendMessage = this . room . maySendMessage ( ) ;
98- this . snapshot . merge ( {
99+ this . snapshot . set ( {
99100 mayDragAndDropFile : maySendMessage ,
100101 options : maySendMessage
101102 ? [
@@ -112,20 +113,11 @@ export class RoomUploadViewModel
112113 ]
113114 : [ ] ,
114115 } ) ;
115- } ;
116+ }
116117
117118 private readonly onUploaderOptionsChanged = ( option : ComposerApiFileUploadOption ) : void => {
118119 this . uploadSelectFns . set ( option . type , option . onSelected ) ;
119- this . snapshot . merge ( {
120- options : [
121- ...this . snapshot . current . options ,
122- {
123- type : option . type ,
124- label : option . label ,
125- icon : option . icon ,
126- } ,
127- ] ,
128- } ) ;
120+ this . updateOptions ( ) ;
129121 } ;
130122
131123 public setReplyToEvent = ( replyToEvent ?: MatrixEvent ) : void => {
0 commit comments