Add new keyboard shortcuts for jump to unread and upload file
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
d63008f9c5
commit
d11923e2e3
3 changed files with 57 additions and 11 deletions
|
@ -34,6 +34,7 @@ export enum Categories {
|
||||||
CALLS = "Calls",
|
CALLS = "Calls",
|
||||||
COMPOSER = "Composer",
|
COMPOSER = "Composer",
|
||||||
ROOM_LIST = "Room List",
|
ROOM_LIST = "Room List",
|
||||||
|
ROOM = "Room",
|
||||||
AUTOCOMPLETE = "Autocomplete",
|
AUTOCOMPLETE = "Autocomplete",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +143,34 @@ const shortcuts: Record<Categories, IShortcut[]> = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
[Categories.ROOM]: [
|
||||||
|
{
|
||||||
|
keybinds: [{
|
||||||
|
key: Key.PAGE_UP,
|
||||||
|
}, {
|
||||||
|
key: Key.PAGE_DOWN,
|
||||||
|
}],
|
||||||
|
description: _td("Scroll up/down in the timeline"),
|
||||||
|
}, {
|
||||||
|
keybinds: [{
|
||||||
|
key: Key.ESCAPE,
|
||||||
|
}],
|
||||||
|
description: _td("Dismiss read marker and jump to bottom"),
|
||||||
|
}, {
|
||||||
|
keybinds: [{
|
||||||
|
modifiers: [Modifiers.SHIFT],
|
||||||
|
key: Key.PAGE_UP,
|
||||||
|
}],
|
||||||
|
description: _td("Jump to oldest unread message"),
|
||||||
|
}, {
|
||||||
|
keybinds: [{
|
||||||
|
modifiers: [CMD_OR_CTRL, Modifiers.SHIFT],
|
||||||
|
key: Key.U,
|
||||||
|
}],
|
||||||
|
description: _td("Upload a file"),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
[Categories.ROOM_LIST]: [
|
[Categories.ROOM_LIST]: [
|
||||||
{
|
{
|
||||||
keybinds: [{
|
keybinds: [{
|
||||||
|
@ -181,13 +210,6 @@ const shortcuts: Record<Categories, IShortcut[]> = {
|
||||||
|
|
||||||
[Categories.NAVIGATION]: [
|
[Categories.NAVIGATION]: [
|
||||||
{
|
{
|
||||||
keybinds: [{
|
|
||||||
key: Key.PAGE_UP,
|
|
||||||
}, {
|
|
||||||
key: Key.PAGE_DOWN,
|
|
||||||
}],
|
|
||||||
description: _td("Scroll up/down in the timeline"),
|
|
||||||
}, {
|
|
||||||
keybinds: [{
|
keybinds: [{
|
||||||
modifiers: [Modifiers.ALT, Modifiers.SHIFT],
|
modifiers: [Modifiers.ALT, Modifiers.SHIFT],
|
||||||
key: Key.ARROW_UP,
|
key: Key.ARROW_UP,
|
||||||
|
@ -257,10 +279,11 @@ const shortcuts: Record<Categories, IShortcut[]> = {
|
||||||
|
|
||||||
const categoryOrder = [
|
const categoryOrder = [
|
||||||
Categories.COMPOSER,
|
Categories.COMPOSER,
|
||||||
Categories.CALLS,
|
|
||||||
Categories.ROOM_LIST,
|
|
||||||
Categories.AUTOCOMPLETE,
|
Categories.AUTOCOMPLETE,
|
||||||
|
Categories.ROOM,
|
||||||
|
Categories.ROOM_LIST,
|
||||||
Categories.NAVIGATION,
|
Categories.NAVIGATION,
|
||||||
|
Categories.CALLS,
|
||||||
];
|
];
|
||||||
|
|
||||||
interface IModal {
|
interface IModal {
|
||||||
|
|
|
@ -41,7 +41,7 @@ import * as ObjectUtils from '../../ObjectUtils';
|
||||||
import * as Rooms from '../../Rooms';
|
import * as Rooms from '../../Rooms';
|
||||||
import eventSearch from '../../Searching';
|
import eventSearch from '../../Searching';
|
||||||
|
|
||||||
import {isOnlyCtrlOrCmdKeyEvent, Key} from '../../Keyboard';
|
import {isOnlyCtrlOrCmdIgnoreShiftKeyEvent, isOnlyCtrlOrCmdKeyEvent, Key} from '../../Keyboard';
|
||||||
|
|
||||||
import MainSplit from './MainSplit';
|
import MainSplit from './MainSplit';
|
||||||
import RightPanel from './RightPanel';
|
import RightPanel from './RightPanel';
|
||||||
|
@ -588,6 +588,18 @@ export default createReactClass({
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Key.PAGE_UP:
|
||||||
|
if (!ev.altKey && !ev.ctrlKey && ev.shiftKey && !ev.metaKey) {
|
||||||
|
this.jumpToReadMarker();
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Key.U.toUpperCase():
|
||||||
|
if (isOnlyCtrlOrCmdIgnoreShiftKeyEvent(ev) && ev.shiftKey) {
|
||||||
|
dis.dispatch({ action: "upload_file" })
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handled) {
|
if (handled) {
|
||||||
|
|
|
@ -114,8 +114,19 @@ class UploadButton extends React.Component {
|
||||||
this.onUploadFileInputChange = this.onUploadFileInputChange.bind(this);
|
this.onUploadFileInputChange = this.onUploadFileInputChange.bind(this);
|
||||||
|
|
||||||
this._uploadInput = createRef();
|
this._uploadInput = createRef();
|
||||||
|
this._dispatcherRef = dis.register(this.onAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
dis.unregister(this._dispatcherRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
onAction = payload => {
|
||||||
|
if (payload.action === "upload_file") {
|
||||||
|
this.onUploadClick();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onUploadClick(ev) {
|
onUploadClick(ev) {
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
dis.dispatch({action: 'require_registration'});
|
dis.dispatch({action: 'require_registration'});
|
||||||
|
@ -128,7 +139,7 @@ class UploadButton extends React.Component {
|
||||||
if (ev.target.files.length === 0) return;
|
if (ev.target.files.length === 0) return;
|
||||||
|
|
||||||
// take a copy so we can safely reset the value of the form control
|
// take a copy so we can safely reset the value of the form control
|
||||||
// (Note it is a FileList: we can't use slice or sesnible iteration).
|
// (Note it is a FileList: we can't use slice or sensible iteration).
|
||||||
const tfiles = [];
|
const tfiles = [];
|
||||||
for (let i = 0; i < ev.target.files.length; ++i) {
|
for (let i = 0; i < ev.target.files.length; ++i) {
|
||||||
tfiles.push(ev.target.files[i]);
|
tfiles.push(ev.target.files[i]);
|
||||||
|
|
Loading…
Reference in a new issue