From 53574541c3a480ee3fda37b642d2e8d1e82c5183 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Mon, 4 Sep 2017 09:31:25 +0200 Subject: [PATCH 1/6] AppTile: Add Jitsi electron screensharing support --- src/components/views/elements/AppTile.js | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 7436f84f69..5a5e266df8 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -19,6 +19,7 @@ limitations under the License. import url from 'url'; import React from 'react'; import MatrixClientPeg from '../../../MatrixClientPeg'; +import PlatformPeg from '../../../PlatformPeg'; import ScalarAuthClient from '../../../ScalarAuthClient'; import SdkConfig from '../../../SdkConfig'; import Modal from '../../../Modal'; @@ -127,6 +128,30 @@ export default React.createClass({ loading: false, }); }); + window.addEventListener('message', this._onMessage, false); + }, + + componentWillUnmount() { + window.removeEventListener('message', this._onMessage); + }, + + _onMessage(event) { + if (!PlatformPeg.get().isElectron() || this.props.type !== 'jitsi') { + return; + } + if (!event.origin) { + event.origin = event.originalEvent.origin; + } + + if (this.state.widgetUrl.indexOf(event.origin) === -1) { + return; + } + + if (event.data.widgetAction === 'jitsi_iframe_loaded') { + const iframe = this.refs.appFrame.contentWindow + .document.querySelector('iframe[id^="jitsiConferenceFrame"]'); + PlatformPeg.get().setupScreenSharingForIframe(iframe); + } }, _canUserModify: function() { From 7f1d8834a25faed2a691ed0b0fa8d6dd48cd4818 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Mon, 25 Sep 2017 17:12:37 +0200 Subject: [PATCH 2/6] Add setupScreenSharingForIframe to BasePlatform --- src/BasePlatform.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index 5f8772c7aa..abc9aa0bed 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -107,6 +107,9 @@ export default class BasePlatform { isElectron(): boolean { return false; } + setupScreenSharingForIframe() { + } + /** * Restarts the application, without neccessarily reloading * any application code From 6e49926228368f64d650d641298ca4f54204fc2c Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Mon, 25 Sep 2017 17:13:18 +0200 Subject: [PATCH 3/6] AppTile: Do not test for electron platform The method platform method is instead stubbed on all other platforms. --- src/components/views/elements/AppTile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 5a5e266df8..2e6a4dab2d 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -136,7 +136,7 @@ export default React.createClass({ }, _onMessage(event) { - if (!PlatformPeg.get().isElectron() || this.props.type !== 'jitsi') { + if (this.props.type !== 'jitsi') { return; } if (!event.origin) { From 24de01e21de03d8abdcc112ea67d43a581c72e5a Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Mon, 25 Sep 2017 17:14:25 +0200 Subject: [PATCH 4/6] AppTile: Test if widgetUrl startsWith instead of has a substring The event origin should be at the beginning of the URL. --- src/components/views/elements/AppTile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 2e6a4dab2d..f4e4702989 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -143,7 +143,7 @@ export default React.createClass({ event.origin = event.originalEvent.origin; } - if (this.state.widgetUrl.indexOf(event.origin) === -1) { + if (!this.state.widgetUrl.startsWith(event.origin)) { return; } From 8d0983ab02bd0329c6331f0e5e3a11aa111e0ddd Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 26 Sep 2017 14:46:57 +0100 Subject: [PATCH 5/6] Fix group membership publicity * Read the new flag in the summary API (the one we were reading was actually whether the group server listed you as a member to non-members). * Remove call to now-dead _loadGroupFromServer andf use the store instead --- src/components/structures/GroupView.js | 14 ++++++-------- src/i18n/strings/en_EN.json | 8 ++++---- src/stores/GroupSummaryStore.js | 6 ++++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 6a30c1ce41..41e58851ff 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -597,9 +597,7 @@ export default React.createClass({ this.setState({ publicityBusy: true, }); - MatrixClientPeg.get().setGroupPublicity(this.props.groupId, publicity).then(() => { - this._loadGroupFromServer(this.props.groupId); - }).then(() => { + this._groupSummaryStore.setGroupPublicity(publicity).then(() => { this.setState({ publicityBusy: false, }); @@ -730,16 +728,16 @@ export default React.createClass({ } let publicisedSection; - if (this.state.summary.user && this.state.summary.user.is_public) { + if (this.state.summary.user && this.state.summary.user.is_publicised) { if (!this.state.publicityBusy) { publicisedButton = - {_t("Make private")} + {_t("Unpublish")} ; } publicisedSection =
- {_t("Your membership of this group is public")} + {_t("This group is published on your profile")}
{publicisedButton}
@@ -749,11 +747,11 @@ export default React.createClass({ publicisedButton = - {_t("Make public")} + {_t("Publish")} ; } publicisedSection =
- {_t("Your membership of this group is private")} + {_t("This group is not published on your profile")}
{publicisedButton}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9dd479c789..8584f2eb2f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -883,8 +883,8 @@ "The user '%(displayName)s' could not be removed from the summary.": "The user '%(displayName)s' could not be removed from the summary.", "Failed to add the following rooms to the summary of %(groupId)s:": "Failed to add the following rooms to the summary of %(groupId)s:", "The room '%(roomName)s' could not be removed from the summary.": "The room '%(roomName)s' could not be removed from the summary.", - "Your membership of this group is public": "Your membership of this group is public", - "Your membership of this group is private": "Your membership of this group is private", - "Make private": "Make private", - "Make public": "Make public" + "Unpublish": "Unpublish", + "This group is published on your profile": "This group is published on your profile", + "Publish": "Publish", + "This group is not published on your profile": "This group is not published on your profile" } diff --git a/src/stores/GroupSummaryStore.js b/src/stores/GroupSummaryStore.js index 170a1ec11e..d066f44b40 100644 --- a/src/stores/GroupSummaryStore.js +++ b/src/stores/GroupSummaryStore.js @@ -68,4 +68,10 @@ export default class GroupSummaryStore extends EventEmitter { .removeUserFromGroupSummary(this._groupId, userId) .then(this._fetchSummary.bind(this)); } + + setGroupPublicity(is_published) { + return this._matrixClient + .setGroupPublicity(this._groupId, is_published) + .then(this._fetchSummary.bind(this)); + } } From 8ec1c3ecf410eb266efd1f574016a2c66ea07e78 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 26 Sep 2017 14:58:49 +0100 Subject: [PATCH 6/6] lint --- src/stores/GroupSummaryStore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stores/GroupSummaryStore.js b/src/stores/GroupSummaryStore.js index d066f44b40..aa6e74529b 100644 --- a/src/stores/GroupSummaryStore.js +++ b/src/stores/GroupSummaryStore.js @@ -69,9 +69,9 @@ export default class GroupSummaryStore extends EventEmitter { .then(this._fetchSummary.bind(this)); } - setGroupPublicity(is_published) { + setGroupPublicity(isPublished) { return this._matrixClient - .setGroupPublicity(this._groupId, is_published) + .setGroupPublicity(this._groupId, isPublished) .then(this._fetchSummary.bind(this)); } }