Remove per node snapshot in favour of single top level snapshot

Summary: In order to support focus mode we need to have only 1 snapshot. In practice this is the case but we are making this more apparant in this diff.

Reviewed By: lblasa

Differential Revision: D41493003

fbshipit-source-id: 19ed7213d15adaea4732f4ec60309efa8dae6f94
This commit is contained in:
Luke De Feo
2022-11-24 09:23:16 -08:00
committed by Facebook GitHub Bot
parent b576060339
commit 01f7fa34e5
3 changed files with 22 additions and 37 deletions

View File

@@ -49,7 +49,9 @@ export function plugin(client: PluginClient<Events>) {
});
const nodes = createState<Map<Id, UINode>>(new Map());
const snapshots = createState<Map<Id, Snapshot>>(new Map());
const snapshot = createState<{nodeId: Id; base64Image: Snapshot} | null>(
null,
);
const treeState = createState<TreeState>({expandedNodes: []});
@@ -71,9 +73,10 @@ export function plugin(client: PluginClient<Events>) {
const seenNodes = new Set<Id>();
client.onMessage('subtreeUpdate', (event) => {
snapshots.update((draft) => {
draft.set(event.rootId, event.snapshot);
});
if (event.snapshot) {
snapshot.set({nodeId: event.rootId, base64Image: event.snapshot});
}
nodes.update((draft) => {
event.nodes.forEach((node) => {
draft.set(node.id, node);
@@ -105,7 +108,7 @@ export function plugin(client: PluginClient<Events>) {
rootId,
nodes,
metadata,
snapshots,
snapshot,
hoveredNodes,
perfEvents,
treeState,