bugfixes
This commit is contained in:
parent
5679d19b30
commit
2d5e522475
@ -2025,8 +2025,10 @@ export default function TrainingTab(props: {
|
|||||||
|
|
||||||
const etaSmoothingRef = useRef<{
|
const etaSmoothingRef = useRef<{
|
||||||
lastAt: number
|
lastAt: number
|
||||||
|
lastRawEtaMs: number
|
||||||
}>({
|
}>({
|
||||||
lastAt: 0,
|
lastAt: 0,
|
||||||
|
lastRawEtaMs: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [trainingNowMs, setTrainingNowMs] = useState(() => Date.now())
|
const [trainingNowMs, setTrainingNowMs] = useState(() => Date.now())
|
||||||
@ -2505,6 +2507,7 @@ export default function TrainingTab(props: {
|
|||||||
if (!trainingRunning) {
|
if (!trainingRunning) {
|
||||||
etaSmoothingRef.current = {
|
etaSmoothingRef.current = {
|
||||||
lastAt: 0,
|
lastAt: 0,
|
||||||
|
lastRawEtaMs: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
setSmoothedTrainingEtaMs(0)
|
setSmoothedTrainingEtaMs(0)
|
||||||
@ -3189,6 +3192,7 @@ export default function TrainingTab(props: {
|
|||||||
if (!trainingRunning || rawTrainingEtaMs <= 0) {
|
if (!trainingRunning || rawTrainingEtaMs <= 0) {
|
||||||
etaSmoothingRef.current = {
|
etaSmoothingRef.current = {
|
||||||
lastAt: 0,
|
lastAt: 0,
|
||||||
|
lastRawEtaMs: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
setSmoothedTrainingEtaMs(0)
|
setSmoothedTrainingEtaMs(0)
|
||||||
@ -3196,32 +3200,41 @@ export default function TrainingTab(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSmoothedTrainingEtaMs((previous) => {
|
setSmoothedTrainingEtaMs((previous) => {
|
||||||
const lastAt = etaSmoothingRef.current.lastAt || trainingNowMs
|
const state = etaSmoothingRef.current
|
||||||
|
|
||||||
|
const lastAt = state.lastAt || trainingNowMs
|
||||||
const elapsed = Math.max(0, trainingNowMs - lastAt)
|
const elapsed = Math.max(0, trainingNowMs - lastAt)
|
||||||
|
|
||||||
// Anzeige zählt zwischen Backend-Updates weiter runter.
|
// 1) Immer erstmal echte Anzeige runterzählen.
|
||||||
const countedDown = previous > 0
|
const countedDown =
|
||||||
|
previous > 0
|
||||||
? Math.max(0, previous - elapsed)
|
? Math.max(0, previous - elapsed)
|
||||||
: rawTrainingEtaMs
|
: rawTrainingEtaMs
|
||||||
|
|
||||||
|
const rawChanged =
|
||||||
|
state.lastRawEtaMs <= 0 ||
|
||||||
|
Math.abs(rawTrainingEtaMs - state.lastRawEtaMs) > 1000
|
||||||
|
|
||||||
|
let next = countedDown
|
||||||
|
|
||||||
|
if (rawChanged) {
|
||||||
const diff = rawTrainingEtaMs - countedDown
|
const diff = rawTrainingEtaMs - countedDown
|
||||||
|
|
||||||
// Nach oben sehr vorsichtig glätten, nach unten etwas schneller.
|
// Neue Backend-Schätzung einblenden, aber nicht hart springen.
|
||||||
const factor = diff > 0 ? 0.08 : 0.18
|
|
||||||
|
|
||||||
let next = countedDown + diff * factor
|
|
||||||
|
|
||||||
// Harte Sprünge zusätzlich begrenzen.
|
|
||||||
if (diff > 0) {
|
if (diff > 0) {
|
||||||
next = Math.min(next, countedDown + 10_000)
|
// Restzeit wurde höher neu berechnet: langsam nach oben.
|
||||||
|
next = countedDown + Math.min(diff * 0.20, 15_000)
|
||||||
} else {
|
} else {
|
||||||
next = Math.max(next, countedDown - 20_000)
|
// Restzeit wurde niedriger neu berechnet: schneller nach unten.
|
||||||
|
next = countedDown + diff * 0.45
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next = Math.max(0, next)
|
next = Math.max(0, next)
|
||||||
|
|
||||||
etaSmoothingRef.current = {
|
etaSmoothingRef.current = {
|
||||||
lastAt: trainingNowMs,
|
lastAt: trainingNowMs,
|
||||||
|
lastRawEtaMs: rawTrainingEtaMs,
|
||||||
}
|
}
|
||||||
|
|
||||||
return next
|
return next
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user