fix: refresh enable backend state

This commit is contained in:
jialin
2026-02-04 14:58:48 +08:00
parent 05c05419fc
commit 7fd2b43704
14 changed files with 74 additions and 27 deletions
@@ -1,8 +1,10 @@
import { enabledBackendsAtom } from '@/atoms/backend';
import GSDrawer from '@/components/scroller-modal/gs-drawer';
import ColumnWrapper from '@/pages/_components/column-wrapper';
import Separator from '@/pages/llmodels/components/separator';
import { useIntl } from '@umijs/max';
import React from 'react';
import { useAtom } from 'jotai';
import React, { useEffect } from 'react';
import styled from 'styled-components';
import { ListItem } from '../config/types';
import useEnableBackend from '../services/use-enable-backend';
@@ -23,6 +25,7 @@ const AddCommunityModal: React.FC<{
const intl = useIntl();
const { handleEnableBackend } = useEnableBackend();
const [currentData, setCurrentData] = React.useState<any>(null);
const [, setEnabledBackendAtom] = useAtom(enabledBackendsAtom);
const handleOnEnable = async (checked: boolean, data: ListItem) => {
await handleEnableBackend({
@@ -32,12 +35,23 @@ const AddCommunityModal: React.FC<{
enabled: checked
}
});
setEnabledBackendAtom({
...data,
enabled: checked
});
onRefresh?.();
};
const handleOnClick = (data: ListItem) => {
setCurrentData(data);
};
useEffect(() => {
if (!open) {
setEnabledBackendAtom(null);
}
}, [open]);
return (
<GSDrawer
open={open}