From 749239a1ca44086c31c34c8ce8ebc6132600f4e8 Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Fri, 19 Jul 2024 01:14:04 +0900 Subject: [PATCH] =?UTF-8?q?=E7=8F=BE=E6=99=82=E7=82=B9=E3=81=AE=E8=B7=AF?= =?UTF-8?q?=E7=B7=9A=E3=81=A0=E3=81=91=E3=81=A7=E7=A8=AE=E5=88=A5=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=82=92=E5=88=A4=E5=AE=9A=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TypeChangeNotify.tsx | 8 ++++++-- src/hooks/useTypeWillChange.ts | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/TypeChangeNotify.tsx b/src/components/TypeChangeNotify.tsx index 2f36e6039..56fe8c1c3 100644 --- a/src/components/TypeChangeNotify.tsx +++ b/src/components/TypeChangeNotify.tsx @@ -12,6 +12,7 @@ import useNextTrainType from '../hooks/useNextTrainType' import stationState from '../store/atoms/station' import themeState from '../store/atoms/theme' import { currentLineSelector } from '../store/selectors/currentLine' +import { currentStationSelector } from '../store/selectors/currentStation' import isTablet from '../utils/isTablet' import { getIsLocal } from '../utils/trainTypeString' import truncateTrainType from '../utils/truncateTrainType' @@ -724,16 +725,19 @@ const JOBars: React.FC = () => { ) } const TypeChangeNotify: React.FC = () => { - const { selectedDirection, stations, selectedBound, station } = + const { selectedDirection, stations, selectedBound } = useRecoilValue(stationState) const { theme } = useRecoilValue(themeState) + const station = useRecoilValue(currentStationSelector({})) const currentLine = useRecoilValue(currentLineSelector) const nextLine = useNextLine() const trainType = useCurrentTrainType() const nextTrainType = useNextTrainType() const currentTypeStations = stations.filter( - (s) => s.trainType?.typeId === trainType?.typeId + (s) => + s.trainType?.typeId === trainType?.typeId && + s.line?.id === currentLine?.id ) const reversedStations = stations.slice().reverse() diff --git a/src/hooks/useTypeWillChange.ts b/src/hooks/useTypeWillChange.ts index 661ff48c5..57257752f 100644 --- a/src/hooks/useTypeWillChange.ts +++ b/src/hooks/useTypeWillChange.ts @@ -1,11 +1,10 @@ import { useMemo } from 'react' -import { useRecoilValue } from 'recoil' -import navigationState from '../store/atoms/navigation' import { getIsLocal } from '../utils/trainTypeString' +import useCurrentTrainType from './useCurrentTrainType' import useNextTrainType from './useNextTrainType' export const useTypeWillChange = (): boolean => { - const { trainType } = useRecoilValue(navigationState) + const trainType = useCurrentTrainType() const nextTrainType = useNextTrainType() const nextTrainTypeIsDifferent = useMemo(() => {