From 2067f51e2c6a768a5a84aef4c6b2e289eec43cd4 Mon Sep 17 00:00:00 2001 From: Jhen Date: Thu, 22 Sep 2016 16:39:24 +0800 Subject: [PATCH] Add shortcuts for Linux / Windows --- app/containers/App.js | 6 ++++-- app/containers/Debugger/index.js | 12 ++++++------ app/reducers/debugger.js | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/containers/App.js b/app/containers/App.js index b04fd4b6..ee3b474e 100644 --- a/app/containers/App.js +++ b/app/containers/App.js @@ -54,6 +54,8 @@ const styles = { }, }; +const shortcutPrefix = process.platform === 'darwin' ? '⌥⌘' : 'Ctrl+Alt+'; + @connect( state => ({ debugger: state.debugger, @@ -131,10 +133,10 @@ export default class App extends Component { return (
- ⌥⌘K to toggle Redux DevTools + {`${shortcutPrefix}K`} to toggle Redux DevTools
- ⌥⌘J to toggle React DevTools + {`${shortcutPrefix}J`} to toggle React DevTools
); diff --git a/app/containers/Debugger/index.js b/app/containers/Debugger/index.js index ab4afdc9..26b56ace 100644 --- a/app/containers/Debugger/index.js +++ b/app/containers/Debugger/index.js @@ -17,8 +17,6 @@ import { connect } from 'react-redux'; import Worker from 'worker?name=debugger.worker.js!./debuggerWorker'; // eslint-disable-line import * as debuggerAtions from '../../actions/debugger'; -const INITIAL_MESSAGE = 'Waiting, press ⌘R in simulator to reload and connect.'; - function setStatusToTitle(status, message) { document.title = `React Native Debugger - ${message}`; } @@ -94,19 +92,21 @@ export default class Debugger extends Component { }; ws.onopen = () => { - this.props.actions.debugger.setDebuggerStatus(INITIAL_MESSAGE); - setStatusToTitle('waiting', INITIAL_MESSAGE); + const { statusMessage } = this.props.debugger; + this.props.actions.debugger.setDebuggerStatus(statusMessage); + setStatusToTitle('waiting', statusMessage); }; ws.onmessage = message => { if (!message.data) { return; } + const { statusMessage } = this.props.debugger; const object = JSON.parse(message.data); if (object.$event === 'client-disconnected') { shutdownJSRuntime(); - setStatusToTitle('waiting', INITIAL_MESSAGE); + setStatusToTitle('waiting', statusMessage); return; } @@ -125,7 +125,7 @@ export default class Debugger extends Component { setStatusToTitle('connected', `Debugger session #${object.id} active.`); } else if (object.method === '$disconnected') { shutdownJSRuntime(); - setStatusToTitle('waiting', INITIAL_MESSAGE); + setStatusToTitle('waiting', statusMessage); } else { // Otherwise, pass through to the worker. const { worker } = this.props.debugger; diff --git a/app/reducers/debugger.js b/app/reducers/debugger.js index 9fe90803..e4566316 100644 --- a/app/reducers/debugger.js +++ b/app/reducers/debugger.js @@ -1,9 +1,10 @@ import { SET_DEBUGGER_STATUS, SET_DEBUGGER_WORKER } from '../actions/debugger'; +const refreshShortcut = process.platform === 'darwin' ? '⌘R' : 'Ctrl+R'; const initialState = { worker: null, status: 'waiting', - statusMessage: 'Waiting, press ⌘R in simulator to reload and connect.', + statusMessage: `Waiting, press ${refreshShortcut} in simulator to reload and connect.`, }; const actionsMap = {