mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(webapp) optimize show case query code (#257)
This commit is contained in:
@@ -16,22 +16,16 @@ const ShowCase: React.FC<Props> = ({ agentId, onSendMsg }) => {
|
|||||||
const [showCaseMap, setShowCaseMap] = useState<ShowCaseMapType>({});
|
const [showCaseMap, setShowCaseMap] = useState<ShowCaseMapType>({});
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const updateData = async (pageNo: number) => {
|
const updateData = async () => {
|
||||||
if (pageNo === 1) {
|
setLoading(true);
|
||||||
setLoading(true);
|
const res = await queryShowCase(agentId, 1, 30);
|
||||||
}
|
setLoading(false);
|
||||||
const res = await queryShowCase(agentId, pageNo, 30);
|
setShowCaseMap(res.data.showCaseMap);
|
||||||
if (pageNo === 1) {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
setShowCaseMap(
|
|
||||||
pageNo === 1 ? res.data.showCaseMap : { ...showCaseMap, ...res.data.showCaseMap }
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (agentId) {
|
if (agentId) {
|
||||||
updateData(1);
|
updateData();
|
||||||
}
|
}
|
||||||
}, [agentId]);
|
}, [agentId]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user