Merge pull request #3241 from matrix-org/bwindels/dofocuscomposer

Restore manual composing focusing logic
pull/21833/head
Bruno Windels 2019-07-23 11:55:44 +00:00 committed by GitHub
commit 58fd828944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View File

@ -498,6 +498,9 @@ export default class ContentMessages {
this.inprogress.push(upload); this.inprogress.push(upload);
dis.dispatch({action: 'upload_started'}); dis.dispatch({action: 'upload_started'});
// Focus the composer view
dis.dispatch({action: 'focus_composer'});
let error; let error;
function onProgress(ev) { function onProgress(ev) {

View File

@ -268,6 +268,8 @@ export default React.createClass({
componentDidMount: function() { componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction); this.dispatcherRef = dis.register(this.onAction);
this.focusComposer = false;
// this can technically be done anywhere but doing this here keeps all // this can technically be done anywhere but doing this here keeps all
// the routing url path logic together. // the routing url path logic together.
if (this.onAliasClick) { if (this.onAliasClick) {
@ -360,6 +362,10 @@ export default React.createClass({
const durationMs = this.stopPageChangeTimer(); const durationMs = this.stopPageChangeTimer();
Analytics.trackPageChange(durationMs); Analytics.trackPageChange(durationMs);
} }
if (this.focusComposer) {
dis.dispatch({action: 'focus_composer'});
this.focusComposer = false;
}
}, },
startPageChangeTimer() { startPageChangeTimer() {
@ -787,6 +793,8 @@ export default React.createClass({
// that has been passed out-of-band (eg. // that has been passed out-of-band (eg.
// room name and avatar from an invite email) // room name and avatar from an invite email)
_viewRoom: function(roomInfo) { _viewRoom: function(roomInfo) {
this.focusComposer = true;
const newState = { const newState = {
view: VIEWS.LOGGED_IN, view: VIEWS.LOGGED_IN,
currentRoomId: roomInfo.room_id || null, currentRoomId: roomInfo.room_id || null,
@ -1360,6 +1368,7 @@ export default React.createClass({
self.firstSyncComplete = true; self.firstSyncComplete = true;
self.firstSyncPromise.resolve(); self.firstSyncPromise.resolve();
dis.dispatch({action: 'focus_composer'});
self.setState({ self.setState({
ready: true, ready: true,
showNotifierToolbar: Notifier.shouldShowToolbar(), showNotifierToolbar: Notifier.shouldShowToolbar(),

View File

@ -135,10 +135,12 @@ module.exports = React.createClass({
_onResendAllClick: function() { _onResendAllClick: function() {
Resend.resendUnsentEvents(this.props.room); Resend.resendUnsentEvents(this.props.room);
dis.dispatch({action: 'focus_composer'});
}, },
_onCancelAllClick: function() { _onCancelAllClick: function() {
Resend.cancelUnsentEvents(this.props.room); Resend.cancelUnsentEvents(this.props.room);
dis.dispatch({action: 'focus_composer'});
}, },
_onShowDevicesClick: function() { _onShowDevicesClick: function() {

View File

@ -222,6 +222,7 @@ export default class MessageEditor extends React.Component {
dis.dispatch({action: 'edit_event', event: nextEvent}); dis.dispatch({action: 'edit_event', event: nextEvent});
} else { } else {
dis.dispatch({action: 'edit_event', event: null}); dis.dispatch({action: 'edit_event', event: null});
dis.dispatch({action: 'focus_composer'});
} }
event.preventDefault(); event.preventDefault();
} }
@ -229,6 +230,7 @@ export default class MessageEditor extends React.Component {
_cancelEdit = () => { _cancelEdit = () => {
dis.dispatch({action: "edit_event", event: null}); dis.dispatch({action: "edit_event", event: null});
dis.dispatch({action: 'focus_composer'});
} }
_hasModifications(newContent) { _hasModifications(newContent) {
@ -255,6 +257,7 @@ export default class MessageEditor extends React.Component {
this.context.matrixClient.sendMessage(roomId, editContent); this.context.matrixClient.sendMessage(roomId, editContent);
dis.dispatch({action: "edit_event", event: null}); dis.dispatch({action: "edit_event", event: null});
dis.dispatch({action: 'focus_composer'});
} }
_cancelPreviousPendingEdit() { _cancelPreviousPendingEdit() {

View File

@ -16,6 +16,7 @@ limitations under the License.
import Resend from './Resend'; import Resend from './Resend';
import sdk from './index'; import sdk from './index';
import dis from './dispatcher';
import Modal from './Modal'; import Modal from './Modal';
import { _t } from './languageHandler'; import { _t } from './languageHandler';
@ -64,6 +65,10 @@ export async function getUnknownDevicesForRoom(matrixClient, room) {
return unknownDevices; return unknownDevices;
} }
function focusComposer() {
dis.dispatch({action: 'focus_composer'});
}
/** /**
* Show the UnknownDeviceDialog for a given room. The dialog will inform the user * 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 * that messages they sent to this room have not been sent due to unknown devices
@ -85,6 +90,7 @@ export function showUnknownDeviceDialogForMessages(matrixClient, room) {
sendAnywayLabel: _t("Send anyway"), sendAnywayLabel: _t("Send anyway"),
sendLabel: _t("Send"), sendLabel: _t("Send"),
onSend: onSendClicked, onSend: onSendClicked,
onFinished: focusComposer,
}, 'mx_Dialog_unknownDevice'); }, 'mx_Dialog_unknownDevice');
}); });
} }