Skip to content

Commit

Permalink
Fix bug with path
Browse files Browse the repository at this point in the history
  • Loading branch information
spaaaacccee committed Apr 24, 2023
1 parent cea7253 commit fe8ae6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions client/src/components/renderer/grid/Path.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Graphics } from "@inlet/react-pixi";
import { Graphics as PixiGraphics } from "@pixi/graphics";
import { isNull, isUndefined, keyBy } from "lodash";
import { isNull, isUndefined, keyBy, range } from "lodash";
import { TraceEvent } from "protocol/Trace";
import { useMemo } from "react";
import { getColor } from "../colors";
Expand All @@ -22,13 +22,13 @@ type PathProps = {

export function Path({ nodes = [], step = 0, scale: { to } }: PathProps) {
const path = useMemo(() => {
const memo = keyBy(nodes, "id");
const memo = range(nodes.length).map((i) => keyBy(nodes.slice(0, i), "id"));
return (s: number) => {
const out = [];
let next: TraceEvent | undefined = nodes[s];
while (next) {
out.push(next);
next = defined(next.pId) ? memo[`${next.pId}`] : undefined;
next = defined(next.pId) ? memo[s][`${next.pId}`] : undefined;
}
return out;
};
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/renderer/mesh/Path.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Graphics } from "@inlet/react-pixi";
import { Graphics as PixiGraphics } from "@pixi/graphics";
import { isNull, isUndefined, keyBy } from "lodash";
import { isNull, isUndefined, keyBy, range } from "lodash";
import { TraceEvent } from "protocol/Trace";
import { useMemo } from "react";
import { getColor } from "../colors";
Expand All @@ -22,13 +22,13 @@ type PathProps = {

export function Path({ nodes = [], step = 0, scale }: PathProps) {
const path = useMemo(() => {
const memo = keyBy(nodes, "id");
const memo = range(nodes.length).map((i) => keyBy(nodes.slice(0, i), "id"));
return (s: number) => {
const out = [];
let next: TraceEvent | undefined = nodes[s];
while (next) {
out.push(next);
next = defined(next.pId) ? memo[`${next.pId}`] : undefined;
next = defined(next.pId) ? memo[s][`${next.pId}`] : undefined;
}
return out;
};
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/renderer/network/Path.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Graphics } from "@inlet/react-pixi";
import { Graphics as PixiGraphics } from "@pixi/graphics";
import { isNull, isUndefined, keyBy } from "lodash";
import { isNull, isUndefined, keyBy, range } from "lodash";
import { TraceEvent } from "protocol/Trace";
import { useMemo } from "react";
import { getColor } from "../colors";
Expand All @@ -22,13 +22,13 @@ type PathProps = {

export function Path({ nodes = [], step = 0, scale: { to } }: PathProps) {
const path = useMemo(() => {
const memo = keyBy(nodes, "id");
const memo = range(nodes.length).map((i) => keyBy(nodes.slice(0, i), "id"));
return (s: number) => {
const out = [];
let next: TraceEvent | undefined = nodes[s];
while (next) {
out.push(next);
next = defined(next.pId) ? memo[`${next.pId}`] : undefined;
next = defined(next.pId) ? memo[s][`${next.pId}`] : undefined;
}
return out;
};
Expand Down

0 comments on commit fe8ae6c

Please sign in to comment.