@@ -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
/**
@@ -519,6 +520,11 @@ export default class AppTile extends React.Component {
519
520
{ target : '_blank' , href : this . _getSafeUrl ( ) , rel : 'noopener noreferrer' } ) . click ( ) ;
520
521
}
521
522
523
+ _onReloadWidgetClick ( e ) {
524
+ // Reload iframe in this way to avoid cross-origin restrictions
525
+ this . refs . appFrame . src = this . refs . appFrame . src ;
526
+ }
527
+
522
528
render ( ) {
523
529
let appTileBody ;
524
530
@@ -606,6 +612,7 @@ export default class AppTile extends React.Component {
606
612
const showPictureSnapshotButton = this . _hasCapability ( 'm.capability.screenshot' ) && this . props . show ;
607
613
const showPictureSnapshotIcon = 'img/camera_green.svg' ;
608
614
const popoutWidgetIcon = 'img/button-new-window.svg' ;
615
+ const reloadWidgetIcon = 'img/button-refresh.svg' ;
609
616
const windowStateIcon = ( this . props . show ? 'img/minimize.svg' : 'img/maximize.svg' ) ;
610
617
611
618
return (
@@ -624,6 +631,16 @@ export default class AppTile extends React.Component {
624
631
{ this . props . showTitle && this . _getTileTitle ( ) }
625
632
</ span >
626
633
< span className = "mx_AppTileMenuBarWidgets" >
634
+ { /* Reload widget */ }
635
+ { this . props . showReload && < TintableSvgButton
636
+ src = { reloadWidgetIcon }
637
+ className = "mx_AppTileMenuBarWidget mx_AppTileMenuBarWidgetPadding"
638
+ title = { _t ( 'Reload widget' ) }
639
+ onClick = { this . _onReloadWidgetClick }
640
+ width = "10"
641
+ height = "10"
642
+ /> }
643
+
627
644
{ /* Popout widget */ }
628
645
{ this . props . showPopout && < TintableSvgButton
629
646
src = { popoutWidgetIcon }
@@ -707,6 +724,11 @@ AppTile.propTypes = {
707
724
showDelete : PropTypes . bool ,
708
725
// Optionally hide the popout widget icon
709
726
showPopout : PropTypes . bool ,
727
+ // Optionally show the reload widget icon
728
+ // This is not currently intended for use with production widgets. However
729
+ // it can be useful when developing persistent widgets in order to avoid
730
+ // having to reload all of riot to get new widget content.
731
+ showReload : PropTypes . bool ,
710
732
// Widget capabilities to allow by default (without user confirmation)
711
733
// NOTE -- Use with caution. This is intended to aid better integration / UX
712
734
// basic widget capabilities, e.g. injecting sticker message events.
@@ -726,6 +748,7 @@ AppTile.defaultProps = {
726
748
showMinimise : true ,
727
749
showDelete : true ,
728
750
showPopout : true ,
751
+ showReload : false ,
729
752
handleMinimisePointerEvents : false ,
730
753
whitelistCapabilities : [ ] ,
731
754
userWidget : false ,
0 commit comments