({ CarDataZ: carZ, PositionZ: posZ, ...initial }: MessageInitial)
| 56 | const intervalRef = useRef<NodeJS.Timeout | null>(null); |
| 57 | |
| 58 | const handleInitial = ({ CarDataZ: carZ, PositionZ: posZ, ...initial }: MessageInitial) => { |
| 59 | updateState(initial); |
| 60 | |
| 61 | Object.keys(buffers).forEach((key) => { |
| 62 | const data = initial[key as keyof typeof initial]; |
| 63 | const buffer = buffers[key as keyof typeof buffers]; |
| 64 | if (data) buffer.push(data); |
| 65 | }); |
| 66 | |
| 67 | if (carZ) { |
| 68 | const carData = inflate<CarData>(carZ); |
| 69 | updateCarData(carData.Entries[0].Cars); |
| 70 | |
| 71 | for (const entry of carData.Entries) { |
| 72 | carBuffer.pushTimed(entry.Cars, utcToLocalMs(entry.Utc)); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | if (posZ) { |
| 77 | const position = inflate<Position>(posZ); |
| 78 | updatePosition(position.Position[0].Entries); |
| 79 | |
| 80 | for (const entry of position.Position) { |
| 81 | posBuffer.pushTimed(entry.Entries, utcToLocalMs(entry.Timestamp)); |
| 82 | } |
| 83 | } |
| 84 | }; |
| 85 | |
| 86 | const handleUpdate = ({ CarDataZ: carZ, PositionZ: posZ, ...update }: MessageUpdate) => { |
| 87 | Object.keys(buffers).forEach((key) => { |
no test coverage detected