Merge branch 'rxl881/snapshot' of https://github.com/matrix-org/matrix-react-sdk into rxl881/snapshot

This commit is contained in:
Richard Lewis 2018-01-04 18:43:18 +00:00
commit da199da798
3 changed files with 26 additions and 4 deletions

View file

@ -253,8 +253,10 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
// Message endpoint already registered
console.warn("Endpoint already registered");
return;
} else {
console.warn(`Adding widget messaging endpoint for ${widgetId}`);
global.mxWidgetMessagingMessageEndpoints.push(endpoint);
}
global.mxWidgetMessagingMessageEndpoints.push(endpoint);
}
}
@ -322,6 +324,9 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
api: "widget",
version: WIDGET_API_VERSION,
});
} else if (action === 'sticker_message') {
console.warn('got widget sticker message', widgetId);
dis.dispatch({action: 'sticker_message', data: event.data.data});
} else {
console.warn("Widget postMessage event unhandled");
this.sendError(event, {message: "The postMessage was unhandled"});

View file

@ -459,8 +459,11 @@ module.exports = React.createClass({
case 'message_sent':
this._checkIfAlone(this.state.room);
break;
case 'inject_sticker':
this.injectSticker(payload.url, payload.info, payload.text);
case 'post_sticker_message':
this.injectSticker(
payload.data.content.url,
payload.data.content.info,
payload.data.description || payload.data.name);
break;
case 'picture_snapshot':
this.uploadFile(payload.file);

View file

@ -333,7 +333,7 @@ export default React.createClass({
* Called when widget iframe has finished loading
*/
_onLoaded() {
// console.warn("App frame", this.refs.appFrame.contentWindow);
console.warn("App frame loaded", this.props.id);
this.widgetMessaging = new WidgetMessaging(this.props.id, this.refs.appFrame.contentWindow);
this.widgetMessaging.startListening();
this.widgetMessaging.addEndpoint(this.props.id, this.props.url);
@ -345,8 +345,22 @@ export default React.createClass({
console.log("Failed to get widget capabilities", this.widgetId, err);
});
this.setState({loading: false});
dis.register(this._onAction);
},
_onAction(payload) {
switch (payload) {
case payload.action === 'sticker_message':
if (this._hasCapability('sticker_message')) {
dis.dispatch({action: 'post_sticker_message', data: payload.data});
} else {
console.warn('Ignoring sticker message. Invalid capability');
}
break;
}
},
/**
* Set remote content title on AppTile
* @param {string} url Url to check for title