From 33f076f2e95a730d5b511b9d192517cf3ba5a98b Mon Sep 17 00:00:00 2001 From: yezian Date: Thu, 25 Apr 2024 17:09:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E9=97=B4=E5=86=85?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=8A=A0=E8=BD=BD=E5=B8=96=E5=AD=90bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- screeens/StreamerSpace/AllSpacePosts/index.jsx | 5 +++++ screeens/StreamerSpace/IronFanSpacePosts/index.jsx | 5 +++++ screeens/StreamerSpace/SuperFanSpacePosts/index.jsx | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/screeens/StreamerSpace/AllSpacePosts/index.jsx b/screeens/StreamerSpace/AllSpacePosts/index.jsx index 8db8fd1..6e27416 100644 --- a/screeens/StreamerSpace/AllSpacePosts/index.jsx +++ b/screeens/StreamerSpace/AllSpacePosts/index.jsx @@ -16,9 +16,12 @@ export default function AllSpacePosts({ zid }) { const [data, setData] = useState([]); const [offset, setOffset] = useState(0); const [more, setMore] = useState(1); + const [isFetching, setIsFetching] = useState(false); const getData = async () => { if (zid === undefined) return; if (!more) return; + if (isFetching) return; + setIsFetching(true); const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = await baseRequest(); @@ -54,6 +57,8 @@ export default function AllSpacePosts({ zid }) { setMore(_data.data.more); } catch (error) { console.error(error); + } finally { + setIsFetching(false); } }; diff --git a/screeens/StreamerSpace/IronFanSpacePosts/index.jsx b/screeens/StreamerSpace/IronFanSpacePosts/index.jsx index 2f33307..4f8d914 100644 --- a/screeens/StreamerSpace/IronFanSpacePosts/index.jsx +++ b/screeens/StreamerSpace/IronFanSpacePosts/index.jsx @@ -16,9 +16,12 @@ export default function IronFanSpacePosts({ zid }) { const [data, setData] = useState([]); const [offset, setOffset] = useState(0); const [more, setMore] = useState(1); + const [isFetching, setIsFetching] = useState(false); const getData = async () => { if (zid === undefined) return; if (!more) return; + if (isFetching) return; + setIsFetching(true); const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = await baseRequest(); @@ -56,6 +59,8 @@ export default function IronFanSpacePosts({ zid }) { setMore(_data.data.more); } catch (error) { console.error(error); + } finally { + setIsFetching(false); } }; diff --git a/screeens/StreamerSpace/SuperFanSpacePosts/index.jsx b/screeens/StreamerSpace/SuperFanSpacePosts/index.jsx index ddbb343..87097ee 100644 --- a/screeens/StreamerSpace/SuperFanSpacePosts/index.jsx +++ b/screeens/StreamerSpace/SuperFanSpacePosts/index.jsx @@ -16,9 +16,12 @@ export default function SuperFanSpacePosts({ zid }) { const [data, setData] = useState([]); const [offset, setOffset] = useState(0); const [more, setMore] = useState(1); + const [isFetching, setIsFetching] = useState(false); const getData = async () => { if (zid === undefined) return; if (!more) return; + if (isFetching) return; + setIsFetching(true); const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = await baseRequest(); @@ -55,6 +58,8 @@ export default function SuperFanSpacePosts({ zid }) { setMore(_data.data.more); } catch (error) { console.error(error); + } finally { + setIsFetching(false); } };