Be able to handle different snapshots for different roots
Summary: ^ This change allows to take different snapshots for different nodes and render them each on the visualiser. At the moment, more than likely, this is not really used. At the same time, it fixes an issue whereas any subtree update can override and set the only visible snapshot. Reviewed By: LukeDefeo, antonk52 Differential Revision: D39821920 fbshipit-source-id: ab8f6a4a2a5e96801c951a4e3009cc571a617f22
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fadaf26f1e
commit
ee9415a8d4
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import {PluginClient, createState, createDataSource} from 'flipper-plugin';
|
||||
import {Events, Id, PerfStatsEvent, UINode} from './types';
|
||||
import {Events, Id, PerfStatsEvent, Snapshot, UINode} from './types';
|
||||
|
||||
export function plugin(client: PluginClient<Events>) {
|
||||
const rootId = createState<Id | undefined>(undefined);
|
||||
@@ -23,11 +23,13 @@ export function plugin(client: PluginClient<Events>) {
|
||||
});
|
||||
|
||||
const nodesAtom = createState<Map<Id, UINode>>(new Map());
|
||||
const snapshotAtom = createState<String | undefined>(undefined);
|
||||
client.onMessage('subtreeUpdate', ({nodes, snapshot}) => {
|
||||
snapshotAtom.set(snapshot);
|
||||
const snapshotsAtom = createState<Map<Id, Snapshot>>(new Map());
|
||||
client.onMessage('subtreeUpdate', (event) => {
|
||||
snapshotsAtom.update((draft) => {
|
||||
draft.set(event.rootId, event.snapshot);
|
||||
});
|
||||
nodesAtom.update((draft) => {
|
||||
for (const node of nodes) {
|
||||
for (const node of event.nodes) {
|
||||
draft.set(node.id, node);
|
||||
}
|
||||
});
|
||||
@@ -38,7 +40,7 @@ export function plugin(client: PluginClient<Events>) {
|
||||
nodesAtom.set(new Map(nodes.map((node) => [node.id, node])));
|
||||
});
|
||||
|
||||
return {rootId, snapshot: snapshotAtom, nodes: nodesAtom, perfEvents};
|
||||
return {rootId, snapshots: snapshotsAtom, nodes: nodesAtom, perfEvents};
|
||||
}
|
||||
|
||||
export {Component} from './components/main';
|
||||
|
||||
Reference in New Issue
Block a user