Skip to content

Commit

Permalink
refactor: simplify useConnectionSetting (clash-verge-rev#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW authored Jun 7, 2024
1 parent 5768b01 commit 7a1f4f9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"ahooks": "^3.8.0",
"axios": "^1.7.2",
"dayjs": "1.11.5",
"foxact": "^0.2.34",
"foxact": "^0.2.35",
"i18next": "^23.11.5",
"lodash-es": "^4.17.21",
"meta-json-schema": "1.18.5-alpha4",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions src/pages/connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Virtuoso } from "react-virtuoso";
import { useTranslation } from "react-i18next";
import { TableChartRounded, TableRowsRounded } from "@mui/icons-material";
import { closeAllConnections } from "@/services/api";
import {
defaultConnectionSetting,
useConnectionSetting,
} from "@/services/states";
import { useConnectionSetting } from "@/services/states";
import { useClashInfo } from "@/hooks/use-clash";
import { BaseEmpty, BasePage } from "@/components/base";
import { useWebsocket } from "@/hooks/use-websocket";
Expand Down Expand Up @@ -38,8 +35,7 @@ const ConnectionsPage = () => {

const [setting, setSetting] = useConnectionSetting();

const isTableLayout =
(setting || defaultConnectionSetting).layout === "table";
const isTableLayout = setting.layout === "table";

const orderOpts: Record<string, OrderFunc> = {
Default: (list) =>
Expand Down
2 changes: 1 addition & 1 deletion src/services/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface IConnectionSetting {
layout: "table" | "list";
}

export const defaultConnectionSetting: IConnectionSetting = { layout: "table" };
const defaultConnectionSetting: IConnectionSetting = { layout: "table" };

export const useConnectionSetting = () =>
useLocalStorage<IConnectionSetting>(
Expand Down

0 comments on commit 7a1f4f9

Please sign in to comment.