@@ -55,6 +55,7 @@ export default class AppTile extends React.Component {
55
55
this . _grantWidgetPermission = this . _grantWidgetPermission . bind ( this ) ;
56
56
this . _revokeWidgetPermission = this . _revokeWidgetPermission . bind ( this ) ;
57
57
this . _onPopoutWidgetClick = this . _onPopoutWidgetClick . bind ( this ) ;
58
+ this . _onReloadWidgetClick = this . _onReloadWidgetClick . bind ( this ) ;
58
59
}
59
60
60
61
/**
@@ -533,6 +534,11 @@ export default class AppTile extends React.Component {
533
534
{ target : '_blank' , href : this . _getSafeUrl ( ) , rel : 'noopener noreferrer' } ) . click ( ) ;
534
535
}
535
536
537
+ _onReloadWidgetClick ( e ) {
538
+ // Reload iframe in this way to avoid cross-origin restrictions
539
+ this . refs . appFrame . src = this . refs . appFrame . src ;
540
+ }
541
+
536
542
render ( ) {
537
543
let appTileBody ;
538
544
@@ -620,6 +626,7 @@ export default class AppTile extends React.Component {
620
626
const showPictureSnapshotButton = this . _hasCapability ( 'm.capability.screenshot' ) && this . props . show ;
621
627
const showPictureSnapshotIcon = 'img/camera_green.svg' ;
622
628
const popoutWidgetIcon = 'img/button-new-window.svg' ;
629
+ const reloadWidgetIcon = 'img/button-refresh.svg' ;
623
630
const windowStateIcon = ( this . props . show ? 'img/minimize.svg' : 'img/maximize.svg' ) ;
624
631
625
632
return (
@@ -638,6 +645,16 @@ export default class AppTile extends React.Component {
638
645
{ this . props . showTitle && this . _getTileTitle ( ) }
639
646
</ span >
640
647
< span className = "mx_AppTileMenuBarWidgets" >
648
+ { /* Reload widget */ }
649
+ { this . props . showReload && < TintableSvgButton
650
+ src = { reloadWidgetIcon }
651
+ className = "mx_AppTileMenuBarWidget mx_AppTileMenuBarWidgetPadding"
652
+ title = { _t ( 'Reload widget' ) }
653
+ onClick = { this . _onReloadWidgetClick }
654
+ width = "10"
655
+ height = "10"
656
+ /> }
657
+
641
658
{ /* Popout widget */ }
642
659
{ this . props . showPopout && < TintableSvgButton
643
660
src = { popoutWidgetIcon }
@@ -721,6 +738,11 @@ AppTile.propTypes = {
721
738
showDelete : PropTypes . bool ,
722
739
// Optionally hide the popout widget icon
723
740
showPopout : PropTypes . bool ,
741
+ // Optionally show the reload widget icon
742
+ // This is not currently intended for use with production widgets. However
743
+ // it can be useful when developing persistent widgets in order to avoid
744
+ // having to reload all of riot to get new widget content.
745
+ showReload : PropTypes . bool ,
724
746
// Widget capabilities to allow by default (without user confirmation)
725
747
// NOTE -- Use with caution. This is intended to aid better integration / UX
726
748
// basic widget capabilities, e.g. injecting sticker message events.
@@ -740,6 +762,7 @@ AppTile.defaultProps = {
740
762
showMinimise : true ,
741
763
showDelete : true ,
742
764
showPopout : true ,
765
+ showReload : false ,
743
766
handleMinimisePointerEvents : false ,
744
767
whitelistCapabilities : [ ] ,
745
768
userWidget : false ,
0 commit comments