(improvement)(webapp) optimize show case query code (#257)

This commit is contained in:
williamhliu
2023-10-18 17:35:38 +08:00
committed by GitHub
parent 65614ed3ba
commit 7b861f563c

View File

@@ -16,22 +16,16 @@ const ShowCase: React.FC<Props> = ({ agentId, onSendMsg }) => {
const [showCaseMap, setShowCaseMap] = useState<ShowCaseMapType>({});
const [loading, setLoading] = useState(false);
const updateData = async (pageNo: number) => {
if (pageNo === 1) {
const updateData = async () => {
setLoading(true);
}
const res = await queryShowCase(agentId, pageNo, 30);
if (pageNo === 1) {
const res = await queryShowCase(agentId, 1, 30);
setLoading(false);
}
setShowCaseMap(
pageNo === 1 ? res.data.showCaseMap : { ...showCaseMap, ...res.data.showCaseMap }
);
setShowCaseMap(res.data.showCaseMap);
};
useEffect(() => {
if (agentId) {
updateData(1);
updateData();
}
}, [agentId]);