File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
client/src/pages/visualiser Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 11import { useQuery } from "@tanstack/react-query" ;
22import {
3+ assign ,
34 clamp ,
45 entries ,
6+ fill ,
57 floor ,
68 head ,
79 last ,
@@ -30,6 +32,12 @@ import {
3032import { optimiseGridMap } from "./optimiseGridMap" ;
3133import { text } from "queries/query" ;
3234
35+ function padArray < T > ( arr : T [ ] , size : number , value : T ) {
36+ if ( arr . length >= size ) return arr ;
37+ const padding = fill ( new Array ( size - arr . length ) , value ) ;
38+ return [ ...arr , ...padding ] ;
39+ }
40+
3341export function processAgent ( agent : string ) {
3442 const reader = new Reader ( agent ) ;
3543 const seeker = new Seeker ( reader , - 1 ) ;
@@ -204,8 +212,12 @@ export function useSolution({
204212 const { sources, paths, timespan } = result ?? { } ;
205213
206214 const getters = useMemo (
207- ( ) => createAgentPositionGetter ( sources ?? [ ] , paths ?? [ ] , timespan ) ,
208- [ sources , paths , timespan ]
215+ ( ) => createAgentPositionGetter ( sources ?? [ ] , padArray (
216+ paths ?? [ ] ,
217+ instance ?. agents ?? 0 ,
218+ ""
219+ ) , timespan ) ,
220+ [ sources , paths , timespan , instance ?. agents ]
209221 ) ;
210222
211223 return {
You can’t perform that action at this time.
0 commit comments