From 9042f9a813e8c909e695ffbe20f81c08eef03b7a Mon Sep 17 00:00:00 2001 From: cwm Date: Wed, 20 Dec 2017 09:50:29 -0600 Subject: add keyboard shortcuts to getting started (fixes #275) --- app/javascript/flavours/glitch/features/ui/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/javascript/flavours/glitch/features/ui') diff --git a/app/javascript/flavours/glitch/features/ui/index.js b/app/javascript/flavours/glitch/features/ui/index.js index a3a12e628..5c80ea07b 100644 --- a/app/javascript/flavours/glitch/features/ui/index.js +++ b/app/javascript/flavours/glitch/features/ui/index.js @@ -20,6 +20,7 @@ import { Compose, Status, GettingStarted, + KeyboardShortcuts, PublicTimeline, CommunityTimeline, AccountTimeline, @@ -63,6 +64,7 @@ const mapStateToProps = state => ({ }); const keyMap = { + help: '?', new: 'n', search: 's', forceNew: 'option+n', @@ -312,6 +314,14 @@ export default class UI extends React.Component { this.hotkeys = c; } + handleHotkeyToggleHelp = () => { + if (this.props.location.pathname === '/keyboard-shortcuts') { + this.context.router.history.goBack(); + } else { + this.context.router.history.push('/keyboard-shortcuts'); + } + } + handleHotkeyGoToHome = () => { this.context.router.history.push('/timelines/home'); } @@ -378,6 +388,7 @@ export default class UI extends React.Component { }); const handlers = { + help: this.handleHotkeyToggleHelp, new: this.handleHotkeyNew, search: this.handleHotkeySearch, forceNew: this.handleHotkeyForceNew, @@ -405,6 +416,7 @@ export default class UI extends React.Component { + -- cgit