Summary: This PR fixes https://github.com/facebook/flipper/issues/798 by adding customizable hotkeys to reload and/or open developer menu in React Native apps.  #### TODO: - [x] Add correct icon for removing content of the hotkey input (currently using `undo`) - cc passy 😄 ## Changelog Add customizable hotkeys to reload and/or open developer menu in React Native apps. Pull Request resolved: https://github.com/facebook/flipper/pull/822 Test Plan: - Run React Native on version `0.62.0-rc.2` (you can use this app: https://github.com/lucasbento/RNWithFlipper); - Open the Preferences window (`⌘,`); - Customise the React Native hotkeys to whatever you want; - Test them out with Flipper's window active and inactive. > **Note**: this has been tested only in macOS. Reviewed By: jknoxville Differential Revision: D20061833 Pulled By: passy fbshipit-source-id: 601d29e07d7de2683d2c70c7c87f0d841aa3559e
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {remote} from 'electron';
|
|
import androidDevice from './androidDevice';
|
|
import metroDevice from './metroDevice';
|
|
import iOSDevice from './iOSDevice';
|
|
import desktopDevice from './desktopDevice';
|
|
import application from './application';
|
|
import tracking from './tracking';
|
|
import server from './server';
|
|
import notifications from './notifications';
|
|
import plugins from './plugins';
|
|
import user from './user';
|
|
import pluginManager from './pluginManager';
|
|
import reactNative from './reactNative';
|
|
|
|
import {Logger} from '../fb-interfaces/Logger';
|
|
import {Store} from '../reducers/index';
|
|
import {Dispatcher} from './types';
|
|
import {notNull} from '../utils/typeUtils';
|
|
|
|
export default function(store: Store, logger: Logger): () => Promise<void> {
|
|
// This only runs in development as when the reload
|
|
// kicks in it doesn't unregister the shortcuts
|
|
if (process.env.NODE_ENV === 'development') {
|
|
remote.globalShortcut.unregisterAll();
|
|
}
|
|
|
|
const dispatchers: Array<Dispatcher> = [
|
|
application,
|
|
store.getState().settingsState.enableAndroid ? androidDevice : null,
|
|
iOSDevice,
|
|
metroDevice,
|
|
desktopDevice,
|
|
tracking,
|
|
server,
|
|
notifications,
|
|
plugins,
|
|
user,
|
|
pluginManager,
|
|
reactNative,
|
|
].filter(notNull);
|
|
const globalCleanup = dispatchers
|
|
.map(dispatcher => dispatcher(store, logger))
|
|
.filter(Boolean);
|
|
return () => {
|
|
return Promise.all(globalCleanup).then(() => {});
|
|
};
|
|
}
|