@@ -75,8 +75,8 @@ interface IAppTileProps {
7575
7676// TODO: Don't use this because it's wrong
7777class ElementWidget extends Widget {
78- constructor ( w ) {
79- super ( w ) ;
78+ constructor ( private rawDefinition : IWidget ) {
79+ super ( rawDefinition ) ;
8080 }
8181
8282 public get templateUrl ( ) : string {
@@ -137,12 +137,7 @@ class ElementWidget extends Widget {
137137
138138 public getCompleteUrl ( params : ITemplateParams , asPopout = false ) : string {
139139 return runTemplate ( asPopout ? this . popoutTemplateUrl : this . templateUrl , {
140- // we need to supply a whole widget to the template, but don't have
141- // easy access to the definition the superclass is using, so be sad
142- // and gutwrench it.
143- // This isn't a problem when the widget architecture is fixed and this
144- // subclass gets deleted.
145- ...super [ 'definition' ] , // XXX: Private member access
140+ ...this . rawDefinition ,
146141 data : this . rawData ,
147142 } , params ) ;
148143 }
@@ -351,18 +346,39 @@ export class StopGapWidget extends EventEmitter {
351346 MatrixClientPeg . get ( ) . on ( 'event' , this . onEvent ) ;
352347 MatrixClientPeg . get ( ) . on ( 'Event.decrypted' , this . onEventDecrypted ) ;
353348
354- if ( WidgetType . JITSI . matches ( this . mockWidget . type ) ) {
355- this . messaging . on ( "action:set_always_on_screen" ,
356- ( ev : CustomEvent < IStickyActionRequest > ) => {
357- if ( this . messaging . hasCapability ( MatrixCapabilities . AlwaysOnScreen ) ) {
349+ this . messaging . on ( `action: ${ WidgetApiFromWidgetAction . UpdateAlwaysOnScreen } ` ,
350+ ( ev : CustomEvent < IStickyActionRequest > ) => {
351+ if ( this . messaging . hasCapability ( MatrixCapabilities . AlwaysOnScreen ) ) {
352+ if ( WidgetType . JITSI . matches ( this . mockWidget . type ) ) {
358353 CountlyAnalytics . instance . trackJoinCall ( this . appTileProps . room . roomId , true , true ) ;
359- ActiveWidgetStore . setWidgetPersistence ( this . mockWidget . id , ev . detail . data . value ) ;
360- ev . preventDefault ( ) ;
361- this . messaging . transport . reply ( ev . detail , < IWidgetApiRequestEmptyData > { } ) ; // ack
362354 }
363- } ,
364- ) ;
365- } else if ( WidgetType . STICKERPICKER . matches ( this . mockWidget . type ) ) {
355+ ActiveWidgetStore . setWidgetPersistence ( this . mockWidget . id , ev . detail . data . value ) ;
356+ ev . preventDefault ( ) ;
357+ this . messaging . transport . reply ( ev . detail , < IWidgetApiRequestEmptyData > { } ) ; // ack
358+ }
359+ } ,
360+ ) ;
361+
362+ // TODO: Replace this event listener with appropriate driver functionality once the API
363+ // establishes a sane way to send events back and forth.
364+ this . messaging . on ( `action:${ WidgetApiFromWidgetAction . SendSticker } ` ,
365+ ( ev : CustomEvent < IStickerActionRequest > ) => {
366+ if ( this . messaging . hasCapability ( MatrixCapabilities . StickerSending ) ) {
367+ // Acknowledge first
368+ ev . preventDefault ( ) ;
369+ this . messaging . transport . reply ( ev . detail , < IWidgetApiRequestEmptyData > { } ) ;
370+
371+ // Send the sticker
372+ defaultDispatcher . dispatch ( {
373+ action : 'm.sticker' ,
374+ data : ev . detail . data ,
375+ widgetId : this . mockWidget . id ,
376+ } ) ;
377+ }
378+ } ,
379+ ) ;
380+
381+ if ( WidgetType . STICKERPICKER . matches ( this . mockWidget . type ) ) {
366382 this . messaging . on ( `action:${ ElementWidgetActions . OpenIntegrationManager } ` ,
367383 ( ev : CustomEvent < IWidgetApiRequest > ) => {
368384 // Acknowledge first
@@ -394,23 +410,6 @@ export class StopGapWidget extends EventEmitter {
394410 }
395411 } ,
396412 ) ;
397-
398- // TODO: Replace this event listener with appropriate driver functionality once the API
399- // establishes a sane way to send events back and forth.
400- this . messaging . on ( `action:${ WidgetApiFromWidgetAction . SendSticker } ` ,
401- ( ev : CustomEvent < IStickerActionRequest > ) => {
402- // Acknowledge first
403- ev . preventDefault ( ) ;
404- this . messaging . transport . reply ( ev . detail , < IWidgetApiRequestEmptyData > { } ) ;
405-
406- // Send the sticker
407- defaultDispatcher . dispatch ( {
408- action : 'm.sticker' ,
409- data : ev . detail . data ,
410- widgetId : this . mockWidget . id ,
411- } ) ;
412- } ,
413- ) ;
414413 }
415414 }
416415
0 commit comments