From 20917e1a07f04c1901fba045bacf16367a82ff97 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 8 Dec 2017 15:12:48 +0000 Subject: [PATCH] Set page title from widget data, if available. --- src/components/views/elements/AppTile.js | 9 ++++++--- src/components/views/rooms/AppsDrawer.js | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 1a5032cf94..9c327d55fe 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -79,7 +79,7 @@ export default React.createClass({ hasPermissionToLoad: hasPermissionToLoad === 'true' || newProps.userId === newProps.creatorUserId, error: null, deleting: false, - widgetPageTitle: null, + widgetPageTitle: newProps.widgetPageTitle, }; }, @@ -197,7 +197,10 @@ export default React.createClass({ initialising: false, }); - this._updateWidgetTitle(params.url); + // Fetch page title from remote content if not already set + if (!this.state.widgetPageTitle) { + this._fetchWidgetTitle(params.url); + } }, (err) => { console.error("Failed to get scalar_token", err); this.setState({ @@ -303,7 +306,7 @@ export default React.createClass({ * Set remote content title on AppTile * @param {string} url Url to check for title */ - _updateWidgetTitle(url) { + _fetchWidgetTitle(url) { this._scalarClient.getScalarPageTitle(url).then((widgetPageTitle) => { if (widgetPageTitle) { this.setState({widgetPageTitle: widgetPageTitle}); diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 423f345b1d..4e4fc5f06c 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -224,6 +224,7 @@ module.exports = React.createClass({ userId={this.props.userId} show={this.props.showApps} creatorUserId={app.creatorUserId} + widgetPageTitle={(app.data && app.data.widgetPageTitle) ? app.data.widgetPageTitle : ''} />); });