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:
@@ -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
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useAppSelector, useAppDispatch } from "@/redux/store";
|
||||
import { initPersistedTimings } from "@/redux/slices/deviceEventsSlice";
|
||||
import { useAppSelector } from "@/redux/store";
|
||||
|
||||
export default function SlotActivityOverlay({
|
||||
slotIndex,
|
||||
@@ -25,32 +24,11 @@ export default function SlotActivityOverlay({
|
||||
const comparisonStartedAtBySlot = useAppSelector(
|
||||
(s) => s.deviceEvents.comparisonStartedAtBySlot
|
||||
);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const loopActive = Array.isArray(ksx) && ksx[slotIndex] === 1;
|
||||
const tdrActive = Array.isArray(ksy) && ksy[slotIndex] === 1;
|
||||
const comparisonActive = Array.isArray(ksz) && ksz[slotIndex] === 1;
|
||||
|
||||
// Load persisted timings only once (on mount)
|
||||
useEffect(() => {
|
||||
try {
|
||||
const raw = localStorage.getItem("deviceEventsTimingsV1");
|
||||
if (raw) {
|
||||
const parsed = JSON.parse(raw);
|
||||
dispatch(
|
||||
initPersistedTimings({
|
||||
loop: parsed.loop,
|
||||
tdr: parsed.tdr,
|
||||
compare: parsed.align || parsed.compare,
|
||||
})
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn("Failed to load persisted timings", e);
|
||||
}
|
||||
}, [dispatch]);
|
||||
|
||||
// Persist whenever arrays change
|
||||
useEffect(() => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user