Skip to content

Commit

Permalink
Added state tracking around init and connected events
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Luke De Feo authored and facebook-github-bot committed Jun 27, 2023
1 parent fcfbc35 commit 05e686d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions desktop/plugins/public/ui-debugger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function plugin(client: PluginClient<Events>) {
const os = client.device.os;

client.onMessage('init', (event) => {
console.log('[ui-debugger] init');
rootId.set(event.rootId);
uiState.frameworkEventMonitoring.update((draft) => {
event.frameworkEventMetadata?.forEach((frameworkEventMeta) => {
Expand All @@ -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(
incomingMetadata: Record<MetadataId, Metadata>,
) {
Expand Down Expand Up @@ -183,6 +194,8 @@ export function plugin(client: PluginClient<Events>) {
const snapshot = createState<SnapshotInfo | null>(null);

const uiState: UIState = {
isConnected: createState(false),

//used to disabled hover effects which cause rerenders and mess up the existing context menu
isContextMenuOpen: createState<boolean>(false),

Expand Down
1 change: 1 addition & 0 deletions desktop/plugins/public/ui-debugger/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import {Atom} from 'flipper-plugin';

export type UIState = {
isConnected: Atom<boolean>;
isPaused: Atom<boolean>;
streamState: Atom<StreamState>;
searchTerm: Atom<string>;
Expand Down

0 comments on commit 05e686d

Please sign in to comment.