From 8308555489448b956236dde3bcbedcd32be3b5d2 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 12:12:37 +0100 Subject: [PATCH 01/16] Mark sync param as optional so that my IDE will stop complaining. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/dispatcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dispatcher.js b/src/dispatcher.js index 9864cb3807..f3ebed8357 100644 --- a/src/dispatcher.js +++ b/src/dispatcher.js @@ -16,13 +16,13 @@ limitations under the License. 'use strict'; -var flux = require("flux"); +const flux = require("flux"); class MatrixDispatcher extends flux.Dispatcher { /** * @param {Object} payload Required. The payload to dispatch. * Must contain at least an 'action' key. - * @param {boolean} sync Optional. Pass true to dispatch + * @param {boolean=} sync Optional. Pass true to dispatch * synchronously. This is useful for anything triggering * an operation that the browser requires user interaction * for. From f200e349c9f7b23b28441871abf94bcfe0d08f94 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 12:50:36 +0100 Subject: [PATCH 02/16] Add .idea to .gitignore file so I don't accidentally upload my IDE config Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5139d614ad..7006c02403 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ npm-debug.log # test reports created by karma /karma-reports + +/.idea From b6ca16fc2f73704536bf93b05db2eeaef040bc98 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 12:56:59 +0100 Subject: [PATCH 03/16] add RoomView state for message being forwarded add RoomView action handler for message forward clear forwardingMessage onCancelClick RoomView change var into const in render RoomView load ForwardMessage from rooms.ForwardMessage if there is a messageForwarding object in state show panel in aux Create ForwardMessage class Modify RoomHeader so that it shows the cancel button more greedily reskindex Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/component-index.js | 2 + src/components/structures/RoomView.js | 48 ++++++---- src/components/views/rooms/ForwardMessage.js | 95 ++++++++++++++++++++ src/components/views/rooms/RoomHeader.js | 3 + 4 files changed, 129 insertions(+), 19 deletions(-) create mode 100644 src/components/views/rooms/ForwardMessage.js diff --git a/src/component-index.js b/src/component-index.js index d6873c6dfd..b9f358467e 100644 --- a/src/component-index.js +++ b/src/component-index.js @@ -183,6 +183,8 @@ import views$rooms$EntityTile from './components/views/rooms/EntityTile'; views$rooms$EntityTile && (module.exports.components['views.rooms.EntityTile'] = views$rooms$EntityTile); import views$rooms$EventTile from './components/views/rooms/EventTile'; views$rooms$EventTile && (module.exports.components['views.rooms.EventTile'] = views$rooms$EventTile); +import views$rooms$ForwardMessage from './components/views/rooms/ForwardMessage'; +views$rooms$ForwardMessage && (module.exports.components['views.rooms.ForwardMessage'] = views$rooms$ForwardMessage); import views$rooms$LinkPreviewWidget from './components/views/rooms/LinkPreviewWidget'; views$rooms$LinkPreviewWidget && (module.exports.components['views.rooms.LinkPreviewWidget'] = views$rooms$LinkPreviewWidget); import views$rooms$MemberDeviceInfo from './components/views/rooms/MemberDeviceInfo'; diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index b09b101b8a..ea221e98b7 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -123,6 +123,8 @@ module.exports = React.createClass({ room: null, roomId: null, roomLoading: true, + + forwardingMessage: null, editingRoomSettings: false, uploadingRoomSettings: false, numUnreadMessages: 0, @@ -437,6 +439,11 @@ module.exports = React.createClass({ callState: callState }); + break; + case 'forward_message': + this.setState({ + forwardingMessage: payload.content, + }); break; } }, @@ -1180,7 +1187,10 @@ module.exports = React.createClass({ onCancelClick: function() { console.log("updateTint from onCancelClick"); this.updateTint(); - this.setState({editingRoomSettings: false}); + this.setState({ + editingRoomSettings: false, + forwardingMessage: null, + }); }, onLeaveClick: function() { @@ -1462,16 +1472,17 @@ module.exports = React.createClass({ }, render: function() { - var RoomHeader = sdk.getComponent('rooms.RoomHeader'); - var MessageComposer = sdk.getComponent('rooms.MessageComposer'); - var RoomSettings = sdk.getComponent("rooms.RoomSettings"); - var AuxPanel = sdk.getComponent("rooms.AuxPanel"); - var SearchBar = sdk.getComponent("rooms.SearchBar"); - var ScrollPanel = sdk.getComponent("structures.ScrollPanel"); - var TintableSvg = sdk.getComponent("elements.TintableSvg"); - var RoomPreviewBar = sdk.getComponent("rooms.RoomPreviewBar"); - var Loader = sdk.getComponent("elements.Spinner"); - var TimelinePanel = sdk.getComponent("structures.TimelinePanel"); + const RoomHeader = sdk.getComponent('rooms.RoomHeader'); + const MessageComposer = sdk.getComponent('rooms.MessageComposer'); + const ForwardMessage = sdk.getComponent("rooms.ForwardMessage"); + const RoomSettings = sdk.getComponent("rooms.RoomSettings"); + const AuxPanel = sdk.getComponent("rooms.AuxPanel"); + const SearchBar = sdk.getComponent("rooms.SearchBar"); + const ScrollPanel = sdk.getComponent("structures.ScrollPanel"); + const TintableSvg = sdk.getComponent("elements.TintableSvg"); + const RoomPreviewBar = sdk.getComponent("rooms.RoomPreviewBar"); + const Loader = sdk.getComponent("elements.Spinner"); + const TimelinePanel = sdk.getComponent("structures.TimelinePanel"); if (!this.state.room) { if (this.state.roomLoading) { @@ -1599,17 +1610,16 @@ module.exports = React.createClass({ />; } - var aux = null; - if (this.state.editingRoomSettings) { + let aux = null; + if (this.state.forwardingMessage !== null) { + aux = ; + } else if (this.state.editingRoomSettings) { aux = ; - } - else if (this.state.uploadingRoomSettings) { + } else if (this.state.uploadingRoomSettings) { aux = ; - } - else if (this.state.searching) { + } else if (this.state.searching) { aux = ; - } - else if (!myMember || myMember.membership !== "join") { + } else if (!myMember || myMember.membership !== "join") { // We do have a room object for this room, but we're not currently in it. // We may have a 3rd party invite to it. var inviterName = undefined; diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js new file mode 100644 index 0000000000..58aac4edd1 --- /dev/null +++ b/src/components/views/rooms/ForwardMessage.js @@ -0,0 +1,95 @@ +/* + Copyright 2017 Vector Creations Ltd + Copyright 2017 Michael Telatynski + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import React from 'react'; +import MatrixClientPeg from '../../../MatrixClientPeg'; +import dis from '../../../dispatcher'; +import KeyCode from "../../../KeyCode"; + + +module.exports = React.createClass({ + displayName: 'ForwardMessage', + + propTypes: { + content: React.PropTypes.object.isRequired, + + // true if RightPanel is collapsed + collapsedRhs: React.PropTypes.bool, + onCancelClick: React.PropTypes.func.isRequired, + }, + + componentWillMount: function() { + this._unmounted = false; + + if (!this.props.collapsedRhs) { + dis.dispatch({ + action: 'hide_right_panel', + }); + } + + dis.dispatch({ + action: 'ui_opacity', + sideOpacity: 1.0, + middleOpacity: 0.3, + }); + }, + + componentDidMount: function() { + this.dispatcherRef = dis.register(this.onAction); + document.addEventListener('keydown', this._onKeyDown); + }, + + componentWillUnmount: function() { + this._unmounted = true; + dis.dispatch({ + action: 'show_right_panel', + }); + dis.dispatch({ + action: 'ui_opacity', + sideOpacity: 1.0, + middleOpacity: 1.0, + }); + dis.unregister(this.dispatcherRef); + document.removeEventListener('keydown', this._onKeyDown); + }, + + onAction: function(payload) { + if (payload.action === 'view_room') { + MatrixClientPeg.get().sendMessage(payload.room_id, this.props.content); + } + }, + + _onKeyDown: function(ev) { + switch (ev.keyCode) { + case KeyCode.ESCAPE: + this.props.onCancelClick(); + dis.dispatch({action: 'focus_composer'}); + break; + } + }, + + render: function() { + return ( +
+ +

Select a room to send the message to

+

Use the left sidebar Room List to select forwarding target

+ +
+ ); + }, +}); diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 94f2691f2c..3d2386070c 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -186,6 +186,9 @@ module.exports = React.createClass({ ); save_button = Save; + } + + if (this.props.onCancelClick) { cancel_button = ; } From 64112da25ccb25797dd1cb9a1727fe5ae6c0a468 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 14:01:04 +0100 Subject: [PATCH 04/16] only re-show right panel if it was visible before we were mounted Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/ForwardMessage.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index 58aac4edd1..efecd1381f 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -55,9 +55,13 @@ module.exports = React.createClass({ componentWillUnmount: function() { this._unmounted = true; - dis.dispatch({ - action: 'show_right_panel', - }); + + if (!this.props.collapsedRhs) { + dis.dispatch({ + action: 'show_right_panel', + }); + } + dis.dispatch({ action: 'ui_opacity', sideOpacity: 1.0, From 589d41e3b9f3e17bb960c67540ac235038ae785c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 18:50:29 +0100 Subject: [PATCH 05/16] DRY the code a little bit in anticipation of #813 which sends a `focus_composer` onCancelClick() Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/ForwardMessage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index efecd1381f..42e2465037 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -81,7 +81,6 @@ module.exports = React.createClass({ switch (ev.keyCode) { case KeyCode.ESCAPE: this.props.onCancelClick(); - dis.dispatch({action: 'focus_composer'}); break; } }, From fbca0e0d0d320d970826d6112b2b793b1a093530 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 20:03:07 +0100 Subject: [PATCH 06/16] correct cancel appearing when it shouldn't Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 9cd5070ad1..91d5e01f78 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1778,7 +1778,7 @@ module.exports = React.createClass({ onSearchClick={this.onSearchClick} onSettingsClick={this.onSettingsClick} onSaveClick={this.onSettingsSaveClick} - onCancelClick={this.onCancelClick} + onCancelClick={aux ? this.onCancelClick : null} onForgetClick={ (myMember && myMember.membership === "leave") ? this.onForgetClick : null } From ee560a969a17591ea39590a61bc0f3327e9df8ab Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 20:17:29 +0100 Subject: [PATCH 07/16] upon forwarding message to current room, explicitly remove clear from aux Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomView.js | 2 +- src/components/views/rooms/ForwardMessage.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 91d5e01f78..e941c6b1a8 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1614,7 +1614,7 @@ module.exports = React.createClass({ let aux = null; if (this.state.forwardingMessage !== null) { - aux = ; + aux = ; } else if (this.state.editingRoomSettings) { aux = ; } else if (this.state.uploadingRoomSettings) { diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index 42e2465037..bb401dde69 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -25,6 +25,7 @@ module.exports = React.createClass({ displayName: 'ForwardMessage', propTypes: { + currentRoomId: React.PropTypes.string.isRequired, content: React.PropTypes.object.isRequired, // true if RightPanel is collapsed @@ -74,6 +75,7 @@ module.exports = React.createClass({ onAction: function(payload) { if (payload.action === 'view_room') { MatrixClientPeg.get().sendMessage(payload.room_id, this.props.content); + if (this.props.currentRoomId === payload.room_id) this.props.onCancelClick(); } }, From 4cf9e0c1ae46d22baef4463376b33c7e577f62cc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 22:00:59 +0100 Subject: [PATCH 08/16] Create a way to restore last state of the rhs panel. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 9b8aa3426a..6df8d99c3a 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -303,6 +303,7 @@ module.exports = React.createClass({ componentDidUpdate: function() { if (this.focusComposer) { + console.log('is this the shitty duplicate?'); dis.dispatch({action: 'focus_composer'}); this.focusComposer = false; } @@ -547,15 +548,23 @@ module.exports = React.createClass({ }); break; case 'hide_right_panel': + this.was_rhs_collapsed = this.state.collapse_rhs; this.setState({ collapse_rhs: true, }); break; case 'show_right_panel': + this.was_rhs_collapsed = this.state.collapse_rhs; this.setState({ collapse_rhs: false, }); break; + // sets the panel to its state before last show/hide event + case 'restore_right_panel': + this.setState({ + collapse_rhs: this.was_rhs_collapsed, + }); + break; case 'ui_opacity': this.setState({ sideOpacity: payload.sideOpacity, From bfba25f3dac7a0279f19300023065032ad251fc3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 22:10:14 +0100 Subject: [PATCH 09/16] we don't care about rhs state anymore as we can just restore it sanely Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index e941c6b1a8..3e43d6984a 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1614,7 +1614,7 @@ module.exports = React.createClass({ let aux = null; if (this.state.forwardingMessage !== null) { - aux = ; + aux = ; } else if (this.state.editingRoomSettings) { aux = ; } else if (this.state.uploadingRoomSettings) { From 28a2266f70ee5aaf18d0eb06333e19a6b9e558cc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 22:11:20 +0100 Subject: [PATCH 10/16] tidy up UDE handler Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/UnknownDeviceErrorHandler.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/UnknownDeviceErrorHandler.js b/src/UnknownDeviceErrorHandler.js index 2aa0573e22..2b1cf23380 100644 --- a/src/UnknownDeviceErrorHandler.js +++ b/src/UnknownDeviceErrorHandler.js @@ -22,7 +22,7 @@ let isDialogOpen = false; const onAction = function(payload) { if (payload.action === 'unknown_device_error' && !isDialogOpen) { - var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog"); + const UnknownDeviceDialog = sdk.getComponent('dialogs.UnknownDeviceDialog'); isDialogOpen = true; Modal.createDialog(UnknownDeviceDialog, { devices: payload.err.devices, @@ -33,17 +33,17 @@ const onAction = function(payload) { // https://github.com/vector-im/riot-web/issues/3148 console.log('UnknownDeviceDialog closed with '+r); }, - }, "mx_Dialog_unknownDevice"); + }, 'mx_Dialog_unknownDevice'); } -} +}; let ref = null; -export function startListening () { +export function startListening() { ref = dis.register(onAction); } -export function stopListening () { +export function stopListening() { if (ref) { dis.unregister(ref); ref = null; From 9ae9aeea0746e5190865491f6602346af6fb1327 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 22:14:45 +0100 Subject: [PATCH 11/16] lets improve forwarding :D ditch double quotes stop caring about rhs state always call hide_right_panel, nop if already hidden use new restore_right_panel to bring it back if it was visible pre-us actually tell things that we sent a message or failed in doing so now the UDE works :D Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/ForwardMessage.js | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index bb401dde69..e5be89b2e0 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -18,7 +18,7 @@ import React from 'react'; import MatrixClientPeg from '../../../MatrixClientPeg'; import dis from '../../../dispatcher'; -import KeyCode from "../../../KeyCode"; +import KeyCode from '../../../KeyCode'; module.exports = React.createClass({ @@ -28,20 +28,13 @@ module.exports = React.createClass({ currentRoomId: React.PropTypes.string.isRequired, content: React.PropTypes.object.isRequired, - // true if RightPanel is collapsed - collapsedRhs: React.PropTypes.bool, onCancelClick: React.PropTypes.func.isRequired, }, componentWillMount: function() { this._unmounted = false; - if (!this.props.collapsedRhs) { - dis.dispatch({ - action: 'hide_right_panel', - }); - } - + dis.dispatch({action: 'hide_right_panel'}); dis.dispatch({ action: 'ui_opacity', sideOpacity: 1.0, @@ -57,12 +50,7 @@ module.exports = React.createClass({ componentWillUnmount: function() { this._unmounted = true; - if (!this.props.collapsedRhs) { - dis.dispatch({ - action: 'show_right_panel', - }); - } - + dis.dispatch({action: 'restore_right_panel'}); dis.dispatch({ action: 'ui_opacity', sideOpacity: 1.0, @@ -74,7 +62,19 @@ module.exports = React.createClass({ onAction: function(payload) { if (payload.action === 'view_room') { - MatrixClientPeg.get().sendMessage(payload.room_id, this.props.content); + const Client = MatrixClientPeg.get(); + Client.sendMessage(payload.room_id, this.props.content).done(() => { + dis.dispatch({action: 'message_sent'}); + }, (err) => { + if (err.name === "UnknownDeviceError") { + dis.dispatch({ + action: 'unknown_device_error', + err: err, + room: Client.getRoom(payload.room_id), + }); + } + dis.dispatch({action: 'message_send_failed'}); + }); if (this.props.currentRoomId === payload.room_id) this.props.onCancelClick(); } }, From 3997974f0f4036af92187ad1d0d50198ad58710a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 24 Apr 2017 22:16:15 +0100 Subject: [PATCH 12/16] remove debug console log (ignore its content pls) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 6df8d99c3a..25ec644787 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -303,7 +303,6 @@ module.exports = React.createClass({ componentDidUpdate: function() { if (this.focusComposer) { - console.log('is this the shitty duplicate?'); dis.dispatch({action: 'focus_composer'}); this.focusComposer = false; } From 0e7e4d8595f71edcd13064760dd810cba0085563 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 May 2017 00:20:32 +0100 Subject: [PATCH 13/16] replace weird sidebar snapping with better ui_opacity Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.js | 14 ++++++------- src/components/structures/MatrixChat.js | 21 ++++++++------------ src/components/views/rooms/ForwardMessage.js | 7 +++---- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 4c012b42a8..6ac7fcb3c4 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -194,7 +194,7 @@ export default React.createClass({ ConferenceHandler={this.props.ConferenceHandler} scrollStateMap={this._scrollStateMap} />; - if (!this.props.collapse_rhs) right_panel = ; + if (!this.props.collapse_rhs) right_panel = ; break; case PageTypes.UserSettings: @@ -206,7 +206,7 @@ export default React.createClass({ referralBaseUrl={this.props.config.referralBaseUrl} teamToken={this.props.teamToken} />; - if (!this.props.collapse_rhs) right_panel = ; + if (!this.props.collapse_rhs) right_panel = ; break; case PageTypes.CreateRoom: @@ -214,7 +214,7 @@ export default React.createClass({ onRoomCreated={this.props.onRoomCreated} collapsedRhs={this.props.collapse_rhs} />; - if (!this.props.collapse_rhs) right_panel = ; + if (!this.props.collapse_rhs) right_panel = ; break; case PageTypes.RoomDirectory: @@ -223,7 +223,7 @@ export default React.createClass({ collapsedRhs={this.props.collapse_rhs} config={this.props.config.roomDirectory} />; - if (!this.props.collapse_rhs) right_panel = ; + if (!this.props.collapse_rhs) right_panel = ; break; case PageTypes.HomePage: @@ -232,12 +232,12 @@ export default React.createClass({ teamServerUrl={this.props.config.teamServerConfig.teamServerURL} teamToken={this.props.teamToken} /> - if (!this.props.collapse_rhs) right_panel = + if (!this.props.collapse_rhs) right_panel = break; case PageTypes.UserView: page_element = null; // deliberately null for now - right_panel = ; + right_panel = ; break; } @@ -266,7 +266,7 @@ export default React.createClass({
diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 25ec644787..c78a395185 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -119,8 +119,9 @@ module.exports = React.createClass({ collapse_rhs: false, ready: false, width: 10000, - sideOpacity: 1.0, + leftOpacity: 1.0, middleOpacity: 1.0, + rightOpacity: 1.0, version: null, newVersion: null, @@ -547,29 +548,23 @@ module.exports = React.createClass({ }); break; case 'hide_right_panel': - this.was_rhs_collapsed = this.state.collapse_rhs; this.setState({ collapse_rhs: true, }); break; case 'show_right_panel': - this.was_rhs_collapsed = this.state.collapse_rhs; this.setState({ collapse_rhs: false, }); break; - // sets the panel to its state before last show/hide event - case 'restore_right_panel': + case 'ui_opacity': { + const sideDefault = payload.sideOpacity >= 0.0 ? payload.sideOpacity : 1.0; this.setState({ - collapse_rhs: this.was_rhs_collapsed, + leftOpacity: payload.leftOpacity >= 0.0 ? payload.leftOpacity : sideDefault, + middleOpacity: payload.middleOpacity || 1.0, + rightOpacity: payload.rightOpacity >= 0.0 ? payload.rightOpacity : sideDefault, }); - break; - case 'ui_opacity': - this.setState({ - sideOpacity: payload.sideOpacity, - middleOpacity: payload.middleOpacity, - }); - break; + break; } case 'set_theme': this._onSetTheme(payload.value); break; diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index e5be89b2e0..cd57bb1ba1 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -34,11 +34,11 @@ module.exports = React.createClass({ componentWillMount: function() { this._unmounted = false; - dis.dispatch({action: 'hide_right_panel'}); dis.dispatch({ action: 'ui_opacity', - sideOpacity: 1.0, - middleOpacity: 0.3, + leftOpacity: 1.0, + rightOpacity: 0.3, + middleOpacity: 0.5, }); }, @@ -50,7 +50,6 @@ module.exports = React.createClass({ componentWillUnmount: function() { this._unmounted = true; - dis.dispatch({action: 'restore_right_panel'}); dis.dispatch({ action: 'ui_opacity', sideOpacity: 1.0, From bf0fe637590897f1e43d39584cef4122a2cf8bf3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 May 2017 00:20:51 +0100 Subject: [PATCH 14/16] don't know why I'm even tracking mounted state. Never refd Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/ForwardMessage.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index cd57bb1ba1..c3cec6fb36 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -32,8 +32,6 @@ module.exports = React.createClass({ }, componentWillMount: function() { - this._unmounted = false; - dis.dispatch({ action: 'ui_opacity', leftOpacity: 1.0, @@ -48,8 +46,6 @@ module.exports = React.createClass({ }, componentWillUnmount: function() { - this._unmounted = true; - dis.dispatch({ action: 'ui_opacity', sideOpacity: 1.0, From 475646a2a73296f25f118ac945b969fa34396df2 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 May 2017 00:34:35 +0100 Subject: [PATCH 15/16] Change wording Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/ForwardMessage.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/views/rooms/ForwardMessage.js b/src/components/views/rooms/ForwardMessage.js index c3cec6fb36..e478630303 100644 --- a/src/components/views/rooms/ForwardMessage.js +++ b/src/components/views/rooms/ForwardMessage.js @@ -85,10 +85,7 @@ module.exports = React.createClass({ render: function() { return (
- -

Select a room to send the message to

-

Use the left sidebar Room List to select forwarding target

- +

Please select the destination room for this message

); }, From cc7edbf86d0154a7b4daa4a4c2bc27a7a8d3e77a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 19 May 2017 01:29:11 +0100 Subject: [PATCH 16/16] allow for sending arbitrary events, also override highlight with event currently being forwarded while forwardingEvent is set Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/RoomView.js | 15 +++++++-------- src/components/views/rooms/ForwardMessage.js | 7 +++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 9a0534cac7..c7417eeafd 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -125,7 +125,7 @@ module.exports = React.createClass({ roomId: null, roomLoading: true, - forwardingMessage: null, + forwardingEvent: null, editingRoomSettings: false, uploadingRoomSettings: false, numUnreadMessages: 0, @@ -454,9 +454,9 @@ module.exports = React.createClass({ }); break; - case 'forward_message': + case 'forward_event': this.setState({ - forwardingMessage: payload.content, + forwardingEvent: payload.content, }); break; } @@ -1203,7 +1203,7 @@ module.exports = React.createClass({ this.updateTint(); this.setState({ editingRoomSettings: false, - forwardingMessage: null, + forwardingEvent: null, }); dis.dispatch({action: 'focus_composer'}); }, @@ -1621,8 +1621,8 @@ module.exports = React.createClass({ } let aux = null; - if (this.state.forwardingMessage !== null) { - aux = ; + if (this.state.forwardingEvent !== null) { + aux = ; } else if (this.state.editingRoomSettings) { aux = ; } else if (this.state.uploadingRoomSettings) { @@ -1742,14 +1742,13 @@ module.exports = React.createClass({ } // console.log("ShowUrlPreview for %s is %s", this.state.room.roomId, this.state.showUrlPreview); - var messagePanel = (