From 0e89afb01f54c452a1a74bf023d17e18b18bde7a Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Mon, 9 Mar 2026 06:46:36 +0800 Subject: [PATCH] fix(window-provider): maximize avoiding loop detection --- src/providers/window/window-provider.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/providers/window/window-provider.tsx b/src/providers/window/window-provider.tsx index 336331021..aab8adc49 100644 --- a/src/providers/window/window-provider.tsx +++ b/src/providers/window/window-provider.tsx @@ -25,13 +25,21 @@ export const WindowProvider: React.FC<{ children: React.ReactNode }> = ({ useEffect(() => { let isUnmounted = false; + let lastWidth = -1; + let lastHeight = -1; - const checkMaximized = debounce(async () => { - if (!isUnmounted) { + const checkMaximized = debounce( + async (event: { payload: { width: number; height: number } }) => { + if (isUnmounted) return; + const { width, height } = event.payload; + if (width === lastWidth && height === lastHeight) return; + lastWidth = width; + lastHeight = height; const value = await currentWindow.isMaximized(); setMaximized(value); - } - }, 300); + }, + 300, + ); const unlistenPromise = currentWindow.onResized(checkMaximized);