mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 06:35:35 +08:00
Merge branch 'rxl881/snapshot' of https://github.com/matrix-org/matrix-react-sdk into rxl881/snapshot
This commit is contained in:
commit
da199da798
@ -253,10 +253,12 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
|
|||||||
// Message endpoint already registered
|
// Message endpoint already registered
|
||||||
console.warn("Endpoint already registered");
|
console.warn("Endpoint already registered");
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
|
console.warn(`Adding widget messaging endpoint for ${widgetId}`);
|
||||||
global.mxWidgetMessagingMessageEndpoints.push(endpoint);
|
global.mxWidgetMessagingMessageEndpoints.push(endpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* De-register a widget endpoint from trusted communication sources
|
* De-register a widget endpoint from trusted communication sources
|
||||||
@ -322,6 +324,9 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
|
|||||||
api: "widget",
|
api: "widget",
|
||||||
version: WIDGET_API_VERSION,
|
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 {
|
} else {
|
||||||
console.warn("Widget postMessage event unhandled");
|
console.warn("Widget postMessage event unhandled");
|
||||||
this.sendError(event, {message: "The postMessage was unhandled"});
|
this.sendError(event, {message: "The postMessage was unhandled"});
|
||||||
|
@ -459,8 +459,11 @@ module.exports = React.createClass({
|
|||||||
case 'message_sent':
|
case 'message_sent':
|
||||||
this._checkIfAlone(this.state.room);
|
this._checkIfAlone(this.state.room);
|
||||||
break;
|
break;
|
||||||
case 'inject_sticker':
|
case 'post_sticker_message':
|
||||||
this.injectSticker(payload.url, payload.info, payload.text);
|
this.injectSticker(
|
||||||
|
payload.data.content.url,
|
||||||
|
payload.data.content.info,
|
||||||
|
payload.data.description || payload.data.name);
|
||||||
break;
|
break;
|
||||||
case 'picture_snapshot':
|
case 'picture_snapshot':
|
||||||
this.uploadFile(payload.file);
|
this.uploadFile(payload.file);
|
||||||
|
@ -333,7 +333,7 @@ export default React.createClass({
|
|||||||
* Called when widget iframe has finished loading
|
* Called when widget iframe has finished loading
|
||||||
*/
|
*/
|
||||||
_onLoaded() {
|
_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 = new WidgetMessaging(this.props.id, this.refs.appFrame.contentWindow);
|
||||||
this.widgetMessaging.startListening();
|
this.widgetMessaging.startListening();
|
||||||
this.widgetMessaging.addEndpoint(this.props.id, this.props.url);
|
this.widgetMessaging.addEndpoint(this.props.id, this.props.url);
|
||||||
@ -345,6 +345,20 @@ export default React.createClass({
|
|||||||
console.log("Failed to get widget capabilities", this.widgetId, err);
|
console.log("Failed to get widget capabilities", this.widgetId, err);
|
||||||
});
|
});
|
||||||
this.setState({loading: false});
|
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;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user