From ceb53dc0bb28d97acee056d99173c74d24e974db Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 23 Jul 2019 09:13:51 +0200 Subject: [PATCH 1/2] Revert "remove unnessary manual focussing of composer" This reverts commit 57abbc42730073365528179f1ea8ad3ceb270367. --- src/ContentMessages.js | 3 +++ src/components/structures/MatrixChat.js | 9 +++++++++ src/components/structures/RoomStatusBar.js | 2 ++ src/components/views/elements/MessageEditor.js | 3 +++ src/cryptodevices.js | 5 +++++ 5 files changed, 22 insertions(+) diff --git a/src/ContentMessages.js b/src/ContentMessages.js index 9317e0b746..2d58622db8 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -498,6 +498,9 @@ export default class ContentMessages { this.inprogress.push(upload); dis.dispatch({action: 'upload_started'}); + // Focus the composer view + dis.dispatch({action: 'focus_composer'}); + let error; function onProgress(ev) { diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index ad3c9ba3fa..db5b7d034b 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -268,6 +268,8 @@ export default React.createClass({ componentDidMount: function() { this.dispatcherRef = dis.register(this.onAction); + this.focusComposer = false; + // this can technically be done anywhere but doing this here keeps all // the routing url path logic together. if (this.onAliasClick) { @@ -360,6 +362,10 @@ export default React.createClass({ const durationMs = this.stopPageChangeTimer(); Analytics.trackPageChange(durationMs); } + if (this.focusComposer) { + dis.dispatch({action: 'focus_composer'}); + this.focusComposer = false; + } }, startPageChangeTimer() { @@ -787,6 +793,8 @@ export default React.createClass({ // that has been passed out-of-band (eg. // room name and avatar from an invite email) _viewRoom: function(roomInfo) { + this.focusComposer = true; + const newState = { view: VIEWS.LOGGED_IN, currentRoomId: roomInfo.room_id || null, @@ -1360,6 +1368,7 @@ export default React.createClass({ self.firstSyncComplete = true; self.firstSyncPromise.resolve(); + dis.dispatch({action: 'focus_composer'}); self.setState({ ready: true, showNotifierToolbar: Notifier.shouldShowToolbar(), diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index bf756b291b..7ef080e235 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -135,10 +135,12 @@ module.exports = React.createClass({ _onResendAllClick: function() { Resend.resendUnsentEvents(this.props.room); + dis.dispatch({action: 'focus_composer'}); }, _onCancelAllClick: function() { Resend.cancelUnsentEvents(this.props.room); + dis.dispatch({action: 'focus_composer'}); }, _onShowDevicesClick: function() { diff --git a/src/components/views/elements/MessageEditor.js b/src/components/views/elements/MessageEditor.js index 86e79a3410..f51348ce04 100644 --- a/src/components/views/elements/MessageEditor.js +++ b/src/components/views/elements/MessageEditor.js @@ -222,6 +222,7 @@ export default class MessageEditor extends React.Component { dis.dispatch({action: 'edit_event', event: nextEvent}); } else { dis.dispatch({action: 'edit_event', event: null}); + dis.dispatch({action: 'focus_composer'}); } event.preventDefault(); } @@ -229,6 +230,7 @@ export default class MessageEditor extends React.Component { _cancelEdit = () => { dis.dispatch({action: "edit_event", event: null}); + dis.dispatch({action: 'focus_composer'}); } _hasModifications(newContent) { @@ -255,6 +257,7 @@ export default class MessageEditor extends React.Component { this.context.matrixClient.sendMessage(roomId, editContent); dis.dispatch({action: "edit_event", event: null}); + dis.dispatch({action: 'focus_composer'}); } _cancelPreviousPendingEdit() { diff --git a/src/cryptodevices.js b/src/cryptodevices.js index 54c96e3976..6f10799300 100644 --- a/src/cryptodevices.js +++ b/src/cryptodevices.js @@ -64,6 +64,10 @@ export async function getUnknownDevicesForRoom(matrixClient, room) { return unknownDevices; } +function focusComposer() { + dis.dispatch({action: 'focus_composer'}); +} + /** * Show the UnknownDeviceDialog for a given room. The dialog will inform the user * that messages they sent to this room have not been sent due to unknown devices @@ -85,6 +89,7 @@ export function showUnknownDeviceDialogForMessages(matrixClient, room) { sendAnywayLabel: _t("Send anyway"), sendLabel: _t("Send"), onSend: onSendClicked, + onFinished: focusComposer, }, 'mx_Dialog_unknownDevice'); }); } From f2bcfea0fb866a91e4d339b0f48f4f3fc76a3197 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 23 Jul 2019 11:43:44 +0200 Subject: [PATCH 2/2] Revert "fix lint" This reverts commit 5c1c1f64b6623c1891f00da3438885f15745161c. --- src/cryptodevices.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptodevices.js b/src/cryptodevices.js index 6f10799300..246fae3d73 100644 --- a/src/cryptodevices.js +++ b/src/cryptodevices.js @@ -16,6 +16,7 @@ limitations under the License. import Resend from './Resend'; import sdk from './index'; +import dis from './dispatcher'; import Modal from './Modal'; import { _t } from './languageHandler';