Refactor node highlighting
Summary: The previous approach would set the atom many times causing several unnecessary renders Reviewed By: lblasa Differential Revision: D47519869 fbshipit-source-id: 536334c892334035a6c0fefc86a2e205b2c9769d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b17c1be12f
commit
34f6b100d7
@@ -281,16 +281,6 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
frameworkEvents.update((draft) => {
|
frameworkEvents.update((draft) => {
|
||||||
if (frameScan?.frameworkEvents) {
|
if (frameScan?.frameworkEvents) {
|
||||||
frameScan.frameworkEvents.forEach((frameworkEvent) => {
|
frameScan.frameworkEvents.forEach((frameworkEvent) => {
|
||||||
if (
|
|
||||||
uiState.frameworkEventMonitoring.get().get(frameworkEvent.type) ===
|
|
||||||
true &&
|
|
||||||
uiState.isPaused.get() === false
|
|
||||||
) {
|
|
||||||
highlightedNodes.update((draft) => {
|
|
||||||
draft.add(frameworkEvent.nodeId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const frameworkEventsForNode = draft.get(frameworkEvent.nodeId);
|
const frameworkEventsForNode = draft.get(frameworkEvent.nodeId);
|
||||||
if (frameworkEventsForNode) {
|
if (frameworkEventsForNode) {
|
||||||
frameworkEventsForNode.push(frameworkEvent);
|
frameworkEventsForNode.push(frameworkEvent);
|
||||||
@@ -298,16 +288,36 @@ export function plugin(client: PluginClient<Events>) {
|
|||||||
draft.set(frameworkEvent.nodeId, [frameworkEvent]);
|
draft.set(frameworkEvent.nodeId, [frameworkEvent]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (uiState.isPaused.get() === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const monitoredEvents = uiState.frameworkEventMonitoring.get();
|
||||||
|
|
||||||
|
const nodesToHighlight =
|
||||||
|
frameScan.frameworkEvents
|
||||||
|
?.filter(
|
||||||
|
(frameworkEvent) => monitoredEvents.get(frameworkEvent.type) === true,
|
||||||
|
)
|
||||||
|
.map((event) => event.nodeId) ?? [];
|
||||||
|
|
||||||
|
highlightedNodes.update((draft) => {
|
||||||
|
for (const node of nodesToHighlight) {
|
||||||
|
draft.add(node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
highlightedNodes.update((laterDraft) => {
|
highlightedNodes.update((draft) => {
|
||||||
for (const event of frameScan.frameworkEvents!!.values()) {
|
for (const nodeId of nodesToHighlight) {
|
||||||
laterDraft.delete(event.nodeId);
|
draft.delete(nodeId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, HighlightTime);
|
}, HighlightTime);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//todo deal with racecondition, where bloks screen is fetching, takes time then you go back get more recent frame then bloks screen comes and overrites it
|
//todo deal with racecondition, where bloks screen is fetching, takes time then you go back get more recent frame then bloks screen comes and overrites it
|
||||||
function applyFrameData(
|
function applyFrameData(
|
||||||
|
|||||||
Reference in New Issue
Block a user