Added state tracking around init and connected events

Summary: Im concerned that we are gettign disconnected without realising, this should help with the logs

Reviewed By: lblasa

Differential Revision: D47053321

fbshipit-source-id: 1014a3e856517e234f0f79f2a4692f18397fc457
This commit is contained in:
Luke De Feo
2023-06-27 04:06:17 -07:00
committed by Facebook GitHub Bot
parent fcfbc352ba
commit 05e686dd47
2 changed files with 14 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ export function plugin(client: PluginClient<Events>) {
const os = client.device.os; const os = client.device.os;
client.onMessage('init', (event) => { client.onMessage('init', (event) => {
console.log('[ui-debugger] init');
rootId.set(event.rootId); rootId.set(event.rootId);
uiState.frameworkEventMonitoring.update((draft) => { uiState.frameworkEventMonitoring.update((draft) => {
event.frameworkEventMetadata?.forEach((frameworkEventMeta) => { event.frameworkEventMetadata?.forEach((frameworkEventMeta) => {
@@ -62,6 +63,16 @@ export function plugin(client: PluginClient<Events>) {
}); });
}); });
client.onConnect(() => {
uiState.isConnected.set(true);
console.log('[ui-debugger] connected');
});
client.onDisconnect(() => {
uiState.isConnected.set(false);
console.log('[ui-debugger] disconnected');
});
async function processMetadata( async function processMetadata(
incomingMetadata: Record<MetadataId, Metadata>, incomingMetadata: Record<MetadataId, Metadata>,
) { ) {
@@ -183,6 +194,8 @@ export function plugin(client: PluginClient<Events>) {
const snapshot = createState<SnapshotInfo | null>(null); const snapshot = createState<SnapshotInfo | null>(null);
const uiState: UIState = { const uiState: UIState = {
isConnected: createState(false),
//used to disabled hover effects which cause rerenders and mess up the existing context menu //used to disabled hover effects which cause rerenders and mess up the existing context menu
isContextMenuOpen: createState<boolean>(false), isContextMenuOpen: createState<boolean>(false),

View File

@@ -10,6 +10,7 @@
import {Atom} from 'flipper-plugin'; import {Atom} from 'flipper-plugin';
export type UIState = { export type UIState = {
isConnected: Atom<boolean>;
isPaused: Atom<boolean>; isPaused: Atom<boolean>;
streamState: Atom<StreamState>; streamState: Atom<StreamState>;
searchTerm: Atom<string>; searchTerm: Atom<string>;