Merge branch 'rxl881/snapshot' of https://github.com/matrix-org/matrix-react-sdk into rxl881/snapshot
This commit is contained in:
commit
da199da798
3 changed files with 26 additions and 4 deletions
|
@ -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"});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue