Decouple android device management from Flipper core/store
Summary: See earlier diffs in the stack. This diff decouple android device management from the Redux store, replacing it with specific events. Reviewed By: timur-valiev Differential Revision: D30286345 fbshipit-source-id: 42f52056bf123b862e2fc087f2e7130c02bdd742
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bf65da0e72
commit
03f2f95a31
@@ -16,15 +16,30 @@ import Client from '../Client';
|
||||
import {notification} from 'antd';
|
||||
|
||||
export default async (store: Store, logger: Logger) => {
|
||||
const {enableAndroid} = store.getState().settingsState;
|
||||
const {enableAndroid, androidHome} = store.getState().settingsState;
|
||||
const server = await startFlipperServer(
|
||||
{
|
||||
enableAndroid,
|
||||
androidHome,
|
||||
serverPorts: store.getState().application.serverPorts,
|
||||
},
|
||||
store,
|
||||
logger,
|
||||
);
|
||||
|
||||
store.dispatch({
|
||||
type: 'SET_FLIPPER_SERVER',
|
||||
payload: server,
|
||||
});
|
||||
|
||||
server.on('notification', (notif) => {
|
||||
notification.open({
|
||||
message: notif.title,
|
||||
description: notif.description,
|
||||
type: notif.type,
|
||||
});
|
||||
});
|
||||
|
||||
server.on('server-start-error', (err) => {
|
||||
notification.error({
|
||||
message: 'Failed to start connection server',
|
||||
@@ -50,6 +65,12 @@ export default async (store: Store, logger: Logger) => {
|
||||
});
|
||||
|
||||
server.on('device-connected', (device) => {
|
||||
logger.track('usage', 'register-device', {
|
||||
os: 'Android',
|
||||
name: device.title,
|
||||
serial: device.serial,
|
||||
});
|
||||
|
||||
device.loadDevicePlugins(
|
||||
store.getState().plugins.devicePlugins,
|
||||
store.getState().connections.enabledDevicePlugins,
|
||||
@@ -61,6 +82,14 @@ export default async (store: Store, logger: Logger) => {
|
||||
});
|
||||
});
|
||||
|
||||
server.on('device-disconnected', (device) => {
|
||||
logger.track('usage', 'unregister-device', {
|
||||
os: device.os,
|
||||
serial: device.serial,
|
||||
});
|
||||
// N.B.: note that we don't remove the device, we keep it in offline mode!
|
||||
});
|
||||
|
||||
server.on('client-connected', (payload) =>
|
||||
handleClientConnected(store, payload),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user