From 666adc6a57d58f1d0bd1e9d3bdca80a0def39bb0 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 8 Jun 2023 10:34:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=96=E5=B1=8F=E4=B8=8B?= =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E5=88=97=E8=A1=A8=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Views/Leaderboard/Vertical/index.tsx | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/screens/Home/Views/Leaderboard/Vertical/index.tsx b/src/screens/Home/Views/Leaderboard/Vertical/index.tsx index 842b162..fea206a 100644 --- a/src/screens/Home/Views/Leaderboard/Vertical/index.tsx +++ b/src/screens/Home/Views/Leaderboard/Vertical/index.tsx @@ -31,20 +31,6 @@ export default () => { const boundInfo = useRef<{ source: LX.OnlineSource, id: string | null }>({ source: 'kw', id: null }) // const [width, setWidth] = useState(0) - useEffect(() => { - const handleFixDrawer = (id: CommonState['navActiveId']) => { - if (id == 'nav_top') drawer.current?.fixWidth() - } - // setWidth(getWindowSise().width * 0.82) - - global.state_event.on('navActiveIdUpdated', handleFixDrawer) - - return () => { - global.state_event.off('navActiveIdUpdated', handleFixDrawer) - // changeEvent.remove() - } - }, []) - const handleBoundChange = (source: LX.OnlineSource, id: string) => { musicListRef.current?.loadList(source, id) void saveLeaderboardSetting({ @@ -108,8 +94,16 @@ export default () => { useEffect(() => { + const handleFixDrawer = (id: CommonState['navActiveId']) => { + if (id == 'nav_top') drawer.current?.fixWidth() + } + global.state_event.on('navActiveIdUpdated', handleFixDrawer) + + isUnmountedRef.current = false void getLeaderboardSetting().then(({ source, boardId }) => { + boundInfo.current.source = source + boundInfo.current.id = boardId void getBoardsList(source).then(list => { const bound = list.find(l => l.id == boardId) boardsListRef.current?.setList(list, boardId) @@ -119,6 +113,7 @@ export default () => { }) return () => { + global.state_event.off('navActiveIdUpdated', handleFixDrawer) isUnmountedRef.current = true } }, [])