From bb89149876e720f8d3152e8d2e2116a942436e4a Mon Sep 17 00:00:00 2001 From: harukin-DeskMini Date: Wed, 1 Feb 2023 16:57:49 +0900 Subject: [PATCH] =?UTF-8?q?=E9=81=B8=E6=8A=9E=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E9=A7=85=E5=90=8D=E6=9D=BF=E3=82=92=E5=88=A9=E7=94=A8=E3=81=97?= =?UTF-8?q?=E3=81=9FLED=E8=A1=A8=E7=A4=BA=E3=81=A8=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E6=95=B4=E5=82=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/menu.js b/menu.js index 0789af4..5a30294 100644 --- a/menu.js +++ b/menu.js @@ -74,6 +74,14 @@ export default function Menu(props) { useEffect(() => { getStationList().then(setOriginalStationList); }, []); + const [locationAndFavorite, setLocationAndFavorite] = useState([]); + useEffect(() => { + if (!favoriteStation) return () => {}; + const data = favoriteStation.filter((d) => + JSON.stringify(d) === JSON.stringify(currentStation) ? false : true + ); + setLocationAndFavorite(data); + }, [currentStation, favoriteStation]); const [stationName, setStationName] = useState(undefined); const [currentStation, setCurrentStation] = useState(undefined); @@ -123,6 +131,7 @@ export default function Menu(props) { const carouselRef = useRef(); const scrollRef = useRef(); const [isScroll, setIsScroll] = useState(true); + const [selectedCurrentStation, setSelectedCurrentStation] = useState(0); useEffect(() => { fetch( @@ -166,11 +175,20 @@ export default function Menu(props) { { + setSelectedCurrentStation(d); + }} renderItem={({ item, index }) => { return ( @@ -185,8 +203,16 @@ export default function Menu(props) { ); }} /> - {currentStation && ( - + {(currentStation || originalStationList) && ( + )}