Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Restore Composer History under shift-up & down #3098

Merged
merged 4 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/components/structures/LoggedInView.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,6 @@ const LoggedInView = React.createClass({
const ctrlCmdOnly = isOnlyCtrlOrCmdKeyEvent(ev);

switch (ev.keyCode) {
case KeyCode.UP:
case KeyCode.DOWN:
if (ev.altKey && !ev.shiftKey && !ev.ctrlKey && !ev.metaKey) {
const action = ev.keyCode == KeyCode.UP ?
'view_prev_room' : 'view_next_room';
dis.dispatch({action: action});
handled = true;
}
break;

case KeyCode.PAGE_UP:
case KeyCode.PAGE_DOWN:
if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) {
Expand Down
39 changes: 17 additions & 22 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1204,9 +1204,7 @@ export default class MessageComposerInput extends React.Component {
};

onVerticalArrow = (e, up) => {
if (e.ctrlKey || e.altKey || e.metaKey) {
return;
}
if (e.ctrlKey || e.shiftKey || e.metaKey) return;

// Select history
const selection = this.state.editorState.selection;
Expand All @@ -1219,34 +1217,31 @@ export default class MessageComposerInput extends React.Component {
if (up) {
if (!selection.anchor.isAtStartOfNode(document)) return;

if (!e.shiftKey) {
const editEvent = findEditableEvent(this.props.room, false);
if (editEvent) {
// We're selecting history, so prevent the key event from doing anything else
e.preventDefault();
dis.dispatch({
action: 'edit_event',
event: editEvent,
});
}
return;
if (!e.altKey) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is redundant now

const editEvent = findEditableEvent(this.props.room, false);
if (editEvent) {
// We're selecting history, so prevent the key event from doing anything else
e.preventDefault();
dis.dispatch({
action: 'edit_event',
event: editEvent,
});
}
} else {
if (!selection.anchor.isAtEndOfNode(document)) return;
return;
}
}

const selected = this.selectHistory(up);
if (selected) {
// We're selecting history, so prevent the key event from doing anything else
e.preventDefault();
}
const selected = this.selectHistory(up);
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
if (selected) {
// We're selecting history, so prevent the key event from doing anything else
e.preventDefault();
}
};

selectHistory = async (up) => {
const delta = up ? -1 : 1;

// True if we are not currently selecting history, but composing a messag
// True if we are not currently selecting history, but composing a message
if (this.historyManager.currentIndex === this.historyManager.history.length) {
// We can't go any further - there isn't any more history, so nop.
if (!up) {
Expand Down