Skip to content

Commit

Permalink
現時点の路線だけで種別変更を判定する
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyKitten committed Jul 18, 2024
1 parent 05adff6 commit 749239a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/components/TypeChangeNotify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useTypeWillChange.ts
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down

0 comments on commit 749239a

Please sign in to comment.