Merge pull request #3576 from matrix-org/travis/widget-tokens

Match widgets up with their integration manager
pull/21833/head
Travis Ralston 2019-10-29 12:16:48 -06:00 committed by GitHub
commit b44e14a722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -190,9 +190,20 @@ export default class AppTile extends React.Component {
// TODO: Pick the right manager for the widget
const defaultManager = managers.getPrimaryManager();
if (!WidgetUtils.isScalarUrl(defaultManager.apiUrl)) {
console.warn('Non-scalar manager, not setting scalar token!', url);
this.setState({
error: null,
widgetUrl: this._addWurlParams(this.props.url),
initialising: false,
});
return;
}
// Fetch the token before loading the iframe as we need it to mangle the URL
if (!this._scalarClient) {
this._scalarClient = managers.getPrimaryManager().getScalarClient();
this._scalarClient = defaultManager.getScalarClient();
}
this._scalarClient.getScalarToken().done((token) => {
// Append scalar_token as a query param if not already present