mirror of https://github.com/vector-im/riot-web
Merge branch 'develop' of github.com:vector-im/element-web into t3chguy/types/react
commit
505eb13461
|
@ -11,6 +11,7 @@
|
|||
"Download Completed": "Download Completed",
|
||||
"Open": "Open",
|
||||
"Dismiss": "Dismiss",
|
||||
"Switch to space by number": "Switch to space by number",
|
||||
"Open user settings": "Open user settings",
|
||||
"Previous/next recently visited room or community": "Previous/next recently visited room or community",
|
||||
"%(brand)s Desktop (%(platformName)s)": "%(brand)s Desktop (%(platformName)s)",
|
||||
|
|
|
@ -37,16 +37,24 @@ import {Room} from "matrix-js-sdk/src/models/room";
|
|||
import Modal from "matrix-react-sdk/src/Modal";
|
||||
import InfoDialog from "matrix-react-sdk/src/components/views/dialogs/InfoDialog";
|
||||
import Spinner from "matrix-react-sdk/src/components/views/elements/Spinner";
|
||||
import {Categories, Modifiers, registerShortcut} from "matrix-react-sdk/src/accessibility/KeyboardShortcuts";
|
||||
import {Key} from "matrix-react-sdk/src/Keyboard";
|
||||
import {
|
||||
Categories,
|
||||
CMD_OR_CTRL,
|
||||
DIGITS,
|
||||
Modifiers,
|
||||
registerShortcut,
|
||||
} from "matrix-react-sdk/src/accessibility/KeyboardShortcuts";
|
||||
import {isOnlyCtrlOrCmdKeyEvent, Key} from "matrix-react-sdk/src/Keyboard";
|
||||
import React from "react";
|
||||
import {randomString} from "matrix-js-sdk/src/randomstring";
|
||||
import {Action} from "matrix-react-sdk/src/dispatcher/actions";
|
||||
import {ActionPayload} from "matrix-react-sdk/src/dispatcher/payloads";
|
||||
import {SwitchSpacePayload} from "matrix-react-sdk/src/dispatcher/payloads/SwitchSpacePayload";
|
||||
import {showToast as showUpdateToast} from "matrix-react-sdk/src/toasts/UpdateToast";
|
||||
import {CheckUpdatesPayload} from "matrix-react-sdk/src/dispatcher/payloads/CheckUpdatesPayload";
|
||||
import ToastStore from "matrix-react-sdk/src/stores/ToastStore";
|
||||
import GenericExpiringToast from "matrix-react-sdk/src/components/views/toasts/GenericExpiringToast";
|
||||
import SettingsStore from 'matrix-react-sdk/src/settings/SettingsStore';
|
||||
|
||||
const electron = window.electron;
|
||||
const isMac = navigator.platform.toUpperCase().includes('MAC');
|
||||
|
@ -270,6 +278,14 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
});
|
||||
|
||||
// register OS-specific shortcuts
|
||||
registerShortcut(Categories.NAVIGATION, {
|
||||
keybinds: [{
|
||||
modifiers: [CMD_OR_CTRL],
|
||||
key: DIGITS,
|
||||
}],
|
||||
description: _td("Switch to space by number"),
|
||||
});
|
||||
|
||||
if (isMac) {
|
||||
registerShortcut(Categories.NAVIGATION, {
|
||||
keybinds: [{
|
||||
|
@ -545,9 +561,15 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
});
|
||||
}
|
||||
|
||||
_navigateForwardBack(back: boolean) {
|
||||
private navigateForwardBack(back: boolean) {
|
||||
this._ipcCall(back ? "navigateBack" : "navigateForward");
|
||||
}
|
||||
private navigateToSpace(num: number) {
|
||||
dis.dispatch<SwitchSpacePayload>({
|
||||
action: Action.SwitchSpace,
|
||||
num,
|
||||
});
|
||||
}
|
||||
|
||||
onKeyDown(ev: KeyboardEvent): boolean {
|
||||
let handled = false;
|
||||
|
@ -556,7 +578,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
case Key.SQUARE_BRACKET_LEFT:
|
||||
case Key.SQUARE_BRACKET_RIGHT:
|
||||
if (isMac && ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey) {
|
||||
this._navigateForwardBack(ev.key === Key.SQUARE_BRACKET_LEFT);
|
||||
this.navigateForwardBack(ev.key === Key.SQUARE_BRACKET_LEFT);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
|
@ -564,7 +586,23 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
case Key.ARROW_LEFT:
|
||||
case Key.ARROW_RIGHT:
|
||||
if (!isMac && ev.altKey && !ev.metaKey && !ev.ctrlKey && !ev.shiftKey) {
|
||||
this._navigateForwardBack(ev.key === Key.ARROW_LEFT);
|
||||
this.navigateForwardBack(ev.key === Key.ARROW_LEFT);
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "1":
|
||||
case "2":
|
||||
case "3":
|
||||
case "4":
|
||||
case "5":
|
||||
case "6":
|
||||
case "7":
|
||||
case "8":
|
||||
case "9":
|
||||
case "0":
|
||||
if (SettingsStore.getValue("feature_spaces") && isOnlyCtrlOrCmdKeyEvent(ev)) {
|
||||
this.navigateToSpace(parseInt(ev.key, 10));
|
||||
handled = true;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue