More batch (#1468)

* batch updates in client

* rearange updating logic

* utilety type

* guard undefinde in affectsLoaded

* fix: pause state not saved to restore point
This commit is contained in:
Alex Christoffer Rasmussen
2025-01-26 13:14:24 +01:00
committed by GitHub
parent bb1e9072fd
commit d34280c03d
6 changed files with 112 additions and 62 deletions
+5 -1
View File
@@ -136,10 +136,14 @@ export function clear() {
* Utility to allow modifying the state from the outside
* @param newState
*/
function patchTimer(newState: Partial<TimerState>) {
function patchTimer(newState: Partial<TimerState & RestorePoint>) {
for (const key in newState) {
if (key in runtimeState.timer) {
runtimeState.timer[key] = newState[key];
} else if (key in runtimeState._timer) {
// in case of a RestorePoint we will receive a pausedAt value
// wiche is needed to resume a paused timer
runtimeState._timer[key] = newState[key];
}
}
}