From e72ad1f030ce33c54a791a9be671ff80c56168cb Mon Sep 17 00:00:00 2001 From: GyDi Date: Wed, 31 Aug 2022 21:44:23 +0800 Subject: [PATCH] fix: remove useless optimizations --- src/components/layout/traffic-graph.tsx | 27 ++----------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/components/layout/traffic-graph.tsx b/src/components/layout/traffic-graph.tsx index 49f3ec0..0a9d376 100644 --- a/src/components/layout/traffic-graph.tsx +++ b/src/components/layout/traffic-graph.tsx @@ -1,7 +1,5 @@ -import { useEffect, useRef, useState } from "react"; +import { useEffect, useRef } from "react"; import { useTheme } from "@mui/material"; -import { listen } from "@tauri-apps/api/event"; -import { appWindow } from "@tauri-apps/api/window"; const maxPoint = 30; @@ -72,28 +70,7 @@ const TrafficGraph = (props: Props) => { }; }, []); - // reduce the GPU usage when hidden - const [enablePaint, setEnablePaint] = useState(true); useEffect(() => { - appWindow.isVisible().then(setEnablePaint); - - const unlistenBlur = listen("tauri://blur", async () => { - setEnablePaint(await appWindow.isVisible()); - }); - - const unlistenFocus = listen("tauri://focus", async () => { - setEnablePaint(await appWindow.isVisible()); - }); - - return () => { - unlistenBlur.then((fn) => fn()); - unlistenFocus.then((fn) => fn()); - }; - }, []); - - useEffect(() => { - if (!enablePaint) return; - let raf = 0; const canvas = canvasRef.current!; @@ -216,7 +193,7 @@ const TrafficGraph = (props: Props) => { return () => { cancelAnimationFrame(raf); }; - }, [enablePaint, palette]); + }, [palette]); return ; };