fix: Timer für jeder KÜ separate und nicht eine für alle, aktuell wird prozentzahl bei allen das gleiche angezeigt

This commit is contained in:
ISA
2025-09-08 10:46:20 +02:00
parent 9c218b2a1d
commit 72341abb23
8 changed files with 44 additions and 32 deletions

View File

@@ -1,7 +1,10 @@
"use client";
import React from "react";
import { useAppDispatch } from "@/redux/store";
import { setEvents } from "@/redux/slices/deviceEventsSlice";
import {
setEvents,
initPersistedTimings,
} from "@/redux/slices/deviceEventsSlice";
declare global {
interface Window {
@@ -18,6 +21,25 @@ export default function DeviceEventsBridge() {
React.useEffect(() => {
let lastSig = "";
// Hydrate persisted timings once
try {
const raw =
typeof window !== "undefined" &&
localStorage.getItem("deviceEventsTimingsV1");
if (raw) {
const parsed = JSON.parse(raw);
dispatch(
initPersistedTimings({
loop: parsed.loop,
tdr: parsed.tdr,
compare: parsed.compare || parsed.align,
})
);
}
} catch (e) {
// eslint-disable-next-line no-console
console.warn("DeviceEventsBridge hydration failed", e);
}
const readAndDispatch = () => {
const ksx = Array.isArray(window.loopMeasurementEvent)
? window.loopMeasurementEvent