diff --git a/src/plugins/metro/index.tsx b/src/chrome/MetroButton.tsx similarity index 63% rename from src/plugins/metro/index.tsx rename to src/chrome/MetroButton.tsx index 47e79f9dc..482ca18a3 100644 --- a/src/plugins/metro/index.tsx +++ b/src/chrome/MetroButton.tsx @@ -7,16 +7,9 @@ * @format */ -import React from 'react'; -import { - FlipperDevicePlugin, - Device, - View, - Button, - Toolbar, - ButtonGroup, - MetroDevice, -} from 'flipper'; +import React, {useCallback} from 'react'; +import {Button, ButtonGroup, MetroDevice, connect} from 'flipper'; +import {State} from '../reducers'; type LogEntry = {}; @@ -24,8 +17,6 @@ export type PersistedState = { logs: LogEntry[]; }; -type State = {}; - /* Flow types for events @@ -120,52 +111,50 @@ export type ReportableEvent = }; */ -export default class MetroPlugin extends FlipperDevicePlugin< - State, - any, - PersistedState -> { - static supportsDevice(device: Device) { - return device.os === 'Metro'; - } +type Props = { + device: MetroDevice; +}; - get ws(): WebSocket { - return (this.device as MetroDevice).ws; - } +function MetroButton({device}: Props) { + const sendCommand = useCallback( + (command: string) => { + if (device.ws) { + device.ws.send( + JSON.stringify({ + version: 2, + type: 'command', + command, + }), + ); + } + }, + [device], + ); - sendCommand(command: string) { - if (this.ws) { - this.ws.send( - JSON.stringify({ - version: 2, - type: 'command', - command, - }), - ); - } - } - - render() { - return ( - - - - Work-in-progress - - - - - - ); - } + return ( + +