Skip to content

Commit

Permalink
BackendList Config
Browse files Browse the repository at this point in the history
  • Loading branch information
haishanh committed Oct 3, 2023
1 parent bae31ea commit 3b2666e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/components/BackendList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,14 @@ export function BackendList() {
// manual clean up is too complex
// we just reload the app
try {
window.location.reload();
window.location.href = '/';
} catch (err) {
// ignore
}
},
[apiConfigs, selectedClashAPIConfigIndex, setSelectedClashAPIConfigIndex],
);

// const {
// app: { selectClashAPIConfig },
// } = useStoreActions();

const onRemove = React.useCallback(
(conf: ClashAPIConfig) => {
removeClashAPIConfig(conf);
Expand Down
19 changes: 4 additions & 15 deletions src/components/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useAtom } from 'jotai';
import * as React from 'react';
import { LogOut } from 'react-feather';
import { useTranslation } from 'react-i18next';
import { redirect } from 'react-router';
import { useNavigate } from 'react-router-dom';

import { updateConfigs } from '$src/api/configs';
import * as logsApi from '$src/api/logs';
Expand Down Expand Up @@ -65,6 +65,7 @@ type ConfigImplProps = {
};

function Config({ configs }: ConfigImplProps) {
const navigate = useNavigate();
const [latencyTestUrl, setLatencyTestUrl] = useAtom(latencyTestUrlAtom);
const [selectedChartStyleIndex, setSelectedChartStyleIndex] = useAtom(
selectedChartStyleIndexAtom,
Expand All @@ -78,12 +79,6 @@ function Config({ configs }: ConfigImplProps) {
}
refConfigs.current = configs;
}, [configs]);

const openAPIConfigModal = useCallback(() => {
redirect('/backend');
// dispatch(openModal('apiConfig'));
}, []);

const setConfigState = useCallback(
(name: keyof ClashGeneralConfig, val: ClashGeneralConfig[keyof ClashGeneralConfig]) => {
setConfigStateInternal({ ...configState, [name]: val });
Expand Down Expand Up @@ -141,12 +136,6 @@ function Config({ configs }: ConfigImplProps) {
(e) => handleChangeValue(e.target),
[handleChangeValue],
);
const selectChartStyleIndex = useCallback(
(idx: number) => {
setSelectedChartStyleIndex(idx);
},
[setSelectedChartStyleIndex],
);

const handleInputOnBlur = useCallback<React.FocusEventHandler<HTMLInputElement>>(
(e) => {
Expand Down Expand Up @@ -259,7 +248,7 @@ function Config({ configs }: ConfigImplProps) {
OptionComponent={TrafficChartSample}
optionPropsList={propsList}
selectedIndex={selectedChartStyleIndex}
onChange={selectChartStyleIndex}
onChange={setSelectedChartStyleIndex}
/>
</div>
<div>
Expand All @@ -271,7 +260,7 @@ function Config({ configs }: ConfigImplProps) {
<Button
start={<LogOut size={16} />}
label={t('switch_backend')}
onClick={openAPIConfigModal}
onClick={() => navigate('/backend')}
/>
</div>
<div className={s0.item}>
Expand Down

0 comments on commit 3b2666e

Please sign in to comment.