Set page title from widget data, if available.

pull/21833/head
Richard Lewis 2017-12-08 15:12:48 +00:00
parent 3206527d73
commit 20917e1a07
2 changed files with 7 additions and 3 deletions

View File

@ -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});

View File

@ -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 : ''}
/>);
});