Skip to content

Commit

Permalink
Merge pull request #3785 from TrainLCD/fix/route-modal-local
Browse files Browse the repository at this point in the history
普通/各停で経路選択を確定できないバグを修正
  • Loading branch information
TinyKitten authored Oct 10, 2024
2 parents 747f7d6 + 5fd6484 commit a6df6db
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/RouteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const RouteList = ({
loading,
}: {
routes: Route[]
onSelect: (item: Route) => void
onSelect: (item: Route | undefined) => void
loading: boolean
}) => {
const [trainTypeInfoModalVisible, setTrainTypeInfoModalVisible] =
Expand Down Expand Up @@ -174,7 +174,7 @@ export const RouteList = ({
disabled={loading}
stations={selectedRoute?.stops ?? []}
onClose={() => setTrainTypeInfoModalVisible(false)}
onConfirmed={() => selectedRoute && onSelect(selectedRoute)}
onConfirmed={() => onSelect(selectedRoute)}
/>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/RouteListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Props = {
isTrainTypesLoading: boolean
error: ConnectError | null
onClose: () => void
onSelect: (route: Route) => void
onSelect: (route: Route | undefined) => void
}

const styles = StyleSheet.create({
Expand Down
6 changes: 3 additions & 3 deletions src/components/TrainTypeInfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Props = {
disabled?: boolean
error: ConnectError | null
onClose: () => void
onConfirmed: (trainType: TrainType) => void
onConfirmed: (trainType: TrainType | undefined) => void
}

const styles = StyleSheet.create({
Expand Down Expand Up @@ -223,8 +223,8 @@ export const TrainTypeInfoModal: React.FC<Props> = ({
<View style={styles.buttons}>
<Button
color={isLEDTheme ? undefined : '#008ffe'}
onPress={() => trainType && onConfirmed(trainType)}
disabled={loading || !trainType || disabled}
onPress={() => onConfirmed(trainType ?? undefined)}
disabled={loading || disabled}
>
{translate('submit')}
</Button>
Expand Down
14 changes: 4 additions & 10 deletions src/screens/RouteSearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,9 @@ const RouteSearchScreen = () => {
selectedLine: stationFromSearch.line ?? null,
}))
setSelectedStation(stationFromSearch)

if (stationFromSearch.hasTrainTypes) {
setIsRouteListModalVisible(true)
return
}

navigation.navigate('SelectBound')
setIsRouteListModalVisible(true)
},
[navigation, setLineState]
[setLineState]
)

const onKeyPress = useCallback(
Expand All @@ -174,8 +168,8 @@ const RouteSearchScreen = () => {
)

const handleSelect = useCallback(
async (route: Route) => {
const trainType = route.stops.find(
async (route: Route | undefined) => {
const trainType = route?.stops.find(
(s) => s.groupId === currentStation?.groupId
)?.trainType

Expand Down

0 comments on commit a6df6db

Please sign in to comment.