Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 6df3371

Browse files
committed
Add a "reload widget" button.
1 parent 1895f82 commit 6df3371

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

res/img/button-refresh.svg

Lines changed: 12 additions & 0 deletions
Loading

src/components/views/elements/AppTile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default class AppTile extends React.Component {
5555
this._grantWidgetPermission = this._grantWidgetPermission.bind(this);
5656
this._revokeWidgetPermission = this._revokeWidgetPermission.bind(this);
5757
this._onPopoutWidgetClick = this._onPopoutWidgetClick.bind(this);
58+
this._onReloadWidgetClick = this._onReloadWidgetClick.bind(this);
5859
}
5960

6061
/**
@@ -519,6 +520,11 @@ export default class AppTile extends React.Component {
519520
{ target: '_blank', href: this._getSafeUrl(), rel: 'noopener noreferrer'}).click();
520521
}
521522

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+
522528
render() {
523529
let appTileBody;
524530

@@ -606,6 +612,7 @@ export default class AppTile extends React.Component {
606612
const showPictureSnapshotButton = this._hasCapability('m.capability.screenshot') && this.props.show;
607613
const showPictureSnapshotIcon = 'img/camera_green.svg';
608614
const popoutWidgetIcon = 'img/button-new-window.svg';
615+
const reloadWidgetIcon = 'img/button-refresh.svg';
609616
const windowStateIcon = (this.props.show ? 'img/minimize.svg' : 'img/maximize.svg');
610617

611618
return (
@@ -624,6 +631,16 @@ export default class AppTile extends React.Component {
624631
{ this.props.showTitle && this._getTileTitle() }
625632
</span>
626633
<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+
627644
{ /* Popout widget */ }
628645
{ this.props.showPopout && <TintableSvgButton
629646
src={popoutWidgetIcon}
@@ -707,6 +724,11 @@ AppTile.propTypes = {
707724
showDelete: PropTypes.bool,
708725
// Optionally hide the popout widget icon
709726
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,
710732
// Widget capabilities to allow by default (without user confirmation)
711733
// NOTE -- Use with caution. This is intended to aid better integration / UX
712734
// basic widget capabilities, e.g. injecting sticker message events.
@@ -726,6 +748,7 @@ AppTile.defaultProps = {
726748
showMinimise: true,
727749
showDelete: true,
728750
showPopout: true,
751+
showReload: false,
729752
handleMinimisePointerEvents: false,
730753
whitelistCapabilities: [],
731754
userWidget: false,

0 commit comments

Comments
 (0)