From 0aca0fba9b19fbd1cb89b4e5332fdf737aaa58cf Mon Sep 17 00:00:00 2001 From: cubemaze Date: Wed, 17 May 2023 18:13:21 +0800 Subject: fix: sidebar state --- src/components/SideBar.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index fbf5a0e..ef17db2 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -9,6 +9,8 @@ import { Link, useLocation } from 'react-router-dom'; import { fetchVersion } from '~/api/version'; import { ThemeSwitcher } from '~/components/shared/ThemeSwitcher'; +import { connect } from '~/components/StateProvider'; +import { getClashAPIConfig } from '~/store/app'; import { ClashAPIConfig } from '~/types'; import s from './SideBar.module.scss'; @@ -80,9 +82,16 @@ const pages = [ }, ]; -export default function SideBar(props: Props) { +const mapState = (s) => ({ + apiConfig: getClashAPIConfig(s), +}); + +export default connect(mapState)(SideBar); + +function SideBar(props: Props) { const { t } = useTranslation(); const location = useLocation(); + const { data: version } = useQuery(['/version', props.apiConfig], () => fetchVersion('/version', props.apiConfig) ); -- cgit v1.3.1