Scope timeout function onto window object

This commit is contained in:
Igor Zinken
2024-02-24 12:36:06 +01:00
parent 61d14f1c12
commit 4a129bab89
2 changed files with 5 additions and 5 deletions

View File

@@ -48,7 +48,7 @@ export const hasQueue = (): boolean => queueLength() > 0;
export const queueLength = (): number => stateQueue.size;
export const flushQueue = (): void => {
clearTimeout( timeout );
window.clearTimeout( timeout );
stateQueue.clear();
};
@@ -80,13 +80,13 @@ export const enqueueState = ( key: string, undoRedoState: UndoRedoState ): void
processQueue();
}
stateQueue.set( key, undoRedoState );
setTimeout( processQueue, ENQUEUE_TIMEOUT );
window.setTimeout( processQueue, ENQUEUE_TIMEOUT );
};
/* internal methods */
function processQueue(): void {
clearTimeout( timeout );
window.clearTimeout( timeout );
stateQueue.forEach( undoRedoState => store.commit( "saveState", undoRedoState ));
stateQueue.clear();
}

View File

@@ -425,14 +425,14 @@ class LayerSprite extends ZoomableSprite {
}
debouncePaintStore( timeout: number = 5000 ): void {
this._pendingPaintState = setTimeout( this.storePaintState.bind( this ), timeout ) as unknown as number;
this._pendingPaintState = window.setTimeout( this.storePaintState.bind( this ), timeout ) as unknown as number;
}
async storePaintState(): Promise<boolean> {
if ( !this._pendingPaintState ) {
return true;
}
clearTimeout( this._pendingPaintState );
window.clearTimeout( this._pendingPaintState );
if ( this._brush.down ) {
// still painting, debounce again (layer.source only updated on handleRelease())
this.debouncePaintStore( 1000 );