From 91eabbba604faed2e062ff777d71c12763c2d9de Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Tue, 13 Jun 2017 15:35:13 +0200 Subject: [PATCH] MessageComposer: Trigger Jitsi app from call buttons --- src/components/structures/ModularWidgets.js | 6 +++ src/components/views/elements/AppTile.js | 2 +- src/components/views/rooms/MessageComposer.js | 40 ++++++++++++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/components/structures/ModularWidgets.js b/src/components/structures/ModularWidgets.js index 4e59fd9cfd..b459241948 100644 --- a/src/components/structures/ModularWidgets.js +++ b/src/components/structures/ModularWidgets.js @@ -12,6 +12,12 @@ class ModularWidgets { name: 'Grafana', description: 'Graph and monitor all the things!', }, + { + type: 'jitsi', + icon: 'http://localhost:8000/static/jitsi.png', + name: 'jitsi', + description: 'Jitsi video conference', + }, { type: 'custom', icon: 'http://localhost:8000/static/blocks.png', diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 3f81ff5067..3bf99dbddd 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -94,7 +94,7 @@ export default React.createClass({
- +
); diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index 63f980304e..24254d989b 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -153,21 +153,41 @@ export default class MessageComposer extends React.Component { }); } - onCallClick(ev) { - console.warn("Call but clicked!"); + _startCallApp(isAudioConf) { dis.dispatch({ - action: 'place_call', - type: ev.shiftKey ? "screensharing" : "video", - room_id: this.props.room.roomId, + action: 'appsDrawer', + show: true, }); + + const appsStateEvents = this.props.room.currentState.getStateEvents('im.vector.modular.widgets', ''); + let appsStateEvent = {}; + if (appsStateEvents) { + appsStateEvent = appsStateEvents.getContent(); + } + if (!appsStateEvent.videoConf) { + appsStateEvent.videoConf = { + type: 'jitsi', + url: 'http://localhost:8000/jitsi.html', + data: { + confId: this.props.room.roomId.replace(/[^A-Za-z0-9]/g, '_') + Date.now(), + isAudioConf: isAudioConf, + }, + }; + MatrixClientPeg.get().sendStateEvent( + this.props.room.roomId, + 'im.vector.modular.widgets', + appsStateEvent, + '', + ).then(() => console.log('Sent state'), (e) => console.error(e)); + } + } + + onCallClick(ev) { + this._startCallApp(false); } onVoiceCallClick(ev) { - dis.dispatch({ - action: 'place_call', - type: 'voice', - room_id: this.props.room.roomId, - }); + this._startCallApp(true); } onShowAppsClick(ev) {