Skip to content

Commit

Permalink
perf(SingleLinePage): don't fetch irrelevant data (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash authored May 21, 2024
1 parent de06832 commit 68e35b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/api/useVehicleLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,19 @@ export default function useVehicleLocations({
lineRef,
operatorRef,
splitMinutes: split = 1,
pause = false,
}: {
from: Dateable
to: Dateable
lineRef?: number
operatorRef?: number
splitMinutes?: false | number
pause?: boolean
}) {
const [locations, setLocations] = useState<VehicleLocation[]>([])
const [isLoading, setIsLoading] = useState<boolean[]>([])
useEffect(() => {
if (pause) return
const range = split ? getMinutesInRange(from, to, split) : [{ from, to }]
setIsLoading(range.map(() => true))
const unmounts = range.map(({ from, to }, i) =>
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useSingleLineData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const useSingleLineData = (lineRef?: number, routeIds?: number[]) => {
from: +new Date(timestamp).setHours(0, 0, 0, 0),
to: +new Date(timestamp).setHours(23, 59, 59, 999),
lineRef,
splitMinutes: 20,
splitMinutes: 60,
pause: !lineRef,
})

const positions = useMemo(() => {
Expand Down

0 comments on commit 68e35b8

Please sign in to comment.