Skip to content

Commit

Permalink
Add shortcuts for Linux / Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Sep 22, 2016
1 parent e036eaf commit 2067f51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 4 additions & 2 deletions app/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const styles = {
},
};

const shortcutPrefix = process.platform === 'darwin' ? '⌥⌘' : 'Ctrl+Alt+';

@connect(
state => ({
debugger: state.debugger,
Expand Down Expand Up @@ -131,10 +133,10 @@ export default class App extends Component {
return (
<div style={styles.wrapBackground}>
<div style={styles.text}>
<kbd style={styles.shortcut}>⌥⌘K</kbd> to toggle Redux DevTools
<kbd style={styles.shortcut}>{`${shortcutPrefix}K`}</kbd> to toggle Redux DevTools
</div>
<div style={styles.text}>
<kbd style={styles.shortcut}>⌥⌘J</kbd> to toggle React DevTools
<kbd style={styles.shortcut}>{`${shortcutPrefix}J`}</kbd> to toggle React DevTools
</div>
</div>
);
Expand Down
12 changes: 6 additions & 6 deletions app/containers/Debugger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion app/reducers/debugger.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down

0 comments on commit 2067f51

Please sign in to comment.