From c321d04374d97b77bd1a9a02504d59496ce409a6 Mon Sep 17 00:00:00 2001 From: Igor Zinken <730069+igorski@users.noreply.github.com> Date: Tue, 3 Mar 2026 21:25:09 +0100 Subject: [PATCH] Fix issue where history state factory would not store reference to pending timeouts --- src/factories/history-state-factory.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/factories/history-state-factory.ts b/src/factories/history-state-factory.ts index 3e56817..0a4f339 100644 --- a/src/factories/history-state-factory.ts +++ b/src/factories/history-state-factory.ts @@ -1,7 +1,7 @@ /** * The MIT License (MIT) * - * Igor Zinken 2021 - https://www.igorski.nl + * Igor Zinken 2021-2026 - https://www.igorski.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -37,7 +37,7 @@ export type UndoRedoState = { const stateQueue = new Map(); const ENQUEUE_TIMEOUT = 1000; -let timeout = 0; +let timeout: ReturnType; let store: Store | undefined; export const initHistory = ( storeReference: Store ): void => { @@ -80,13 +80,13 @@ export const enqueueState = ( key: string, undoRedoState: UndoRedoState ): void processQueue(); } stateQueue.set( key, undoRedoState ); - window.setTimeout( processQueue, ENQUEUE_TIMEOUT ); + timeout = setTimeout( processQueue, ENQUEUE_TIMEOUT ); }; /* internal methods */ function processQueue(): void { - window.clearTimeout( timeout ); + clearTimeout( timeout ); stateQueue.forEach( undoRedoState => store?.commit( "saveState", undoRedoState )); stateQueue.clear(); }