From 6d23182f5ff8f675876c9cfa62d15cf34e7eb476 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 17 Nov 2017 14:54:44 +0000 Subject: [PATCH] Fix the force TURN option The call object is created within the js-sdk for inbound calls, so we never got the chance to set it. --- src/CallHandler.js | 5 +---- src/MatrixClientPeg.js | 4 ++++ src/components/structures/UserSettings.js | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index a9539d40e1..dd9d93709f 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -52,7 +52,6 @@ limitations under the License. */ import MatrixClientPeg from './MatrixClientPeg'; -import UserSettingsStore from './UserSettingsStore'; import PlatformPeg from './PlatformPeg'; import Modal from './Modal'; import sdk from './index'; @@ -245,9 +244,7 @@ function _onAction(payload) { return; } else if (members.length === 2) { console.log("Place %s call in %s", payload.type, payload.room_id); - const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), payload.room_id, { - forceTURN: UserSettingsStore.getLocalSetting('webRtcForceTURN', false), - }); + const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), payload.room_id); placeCall(call); } else { // > 2 dis.dispatch({ diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 0c3d5b3775..6135a91dea 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -136,6 +136,9 @@ class MatrixClientPeg { } _createClient(creds: MatrixClientCreds) { + // XXX: This is here and as a require because apparently circular dependencies + // are just broken in webpack (https://github.com/webpack/webpack/issues/1788) + const UserSettingsStore = require('./UserSettingsStore'); const opts = { baseUrl: creds.homeserverUrl, idBaseUrl: creds.identityServerUrl, @@ -143,6 +146,7 @@ class MatrixClientPeg { userId: creds.userId, deviceId: creds.deviceId, timelineSupport: true, + forceTURN: UserSettingsStore.getLocalSetting('webRtcForceTURN', false), }; this.matrixClient = createMatrixClient(opts, this.indexedDbWorkerScript); diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 68ea932f93..7d45179a1b 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -877,6 +877,11 @@ module.exports = React.createClass({ // TODO: this ought to be a separate component so that we don't need // to rebind the onChange each time we render const onChange = (e) => { + // XXX: awful, but at time of writing, granular settings has landed on + // develop which will almost certainly mean we'll handle this differently. + if (setting.id === 'webRtcForceTURN') { + MatrixClientPeg.get().setForceTURN(e.target.checked); + } UserSettingsStore.setLocalSetting(setting.id, e.target.checked); if (setting.fn) setting.fn(e.target.checked); };