Skip to content

Commit e166b6c

Browse files
TinyKittenclaude
andcommitted
レビュー指摘の修正: テーマ対応テキスト色、sentinel値防止、transition中のボタン無効化、fetch競合対策
- RouteInfoModal: expandableToggleTextをLEDテーマ対応に分岐 - SelectBoundModal: handleToggleNotificationでstation.id nullチェックを追加し-1 sentinel防止 - SelectBoundModal: isTransitioning中に停車駅一覧・種別・保存・設定ボタンも無効化 - usePresetCarouselData: requestIdによるfetch競合対策を追加 - usePresetCarouselData: displayKeyにnotifyStationIdsを追加 - SelectBoundModal: effectiveStationのコメントを実態に合わせて修正 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d47b412 commit e166b6c

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

src/components/RouteInfoModal.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@ const styles = StyleSheet.create({
8383
elevation: 0,
8484
shadowOpacity: 0,
8585
},
86-
expandableToggleText: {
86+
expandableToggleTextLight: {
8787
color: '#333',
8888
},
89+
expandableToggleTextLED: {
90+
color: '#fff',
91+
},
8992
});
9093

9194
type Props = {
@@ -182,7 +185,11 @@ export const RouteInfoModal = ({
182185
onToggle={() => onToggleNotification(item)}
183186
state={isNotifyEnabled}
184187
style={styles.expandableToggle}
185-
textStyle={styles.expandableToggleText}
188+
textStyle={
189+
isLEDTheme
190+
? styles.expandableToggleTextLED
191+
: styles.expandableToggleTextLight
192+
}
186193
activeOpacity={1}
187194
>
188195
{translate('enableNotificationMode')}
@@ -192,7 +199,11 @@ export const RouteInfoModal = ({
192199
<ToggleButton
193200
outline
194201
style={styles.expandableToggle}
195-
textStyle={styles.expandableToggleText}
202+
textStyle={
203+
isLEDTheme
204+
? styles.expandableToggleTextLED
205+
: styles.expandableToggleTextLight
206+
}
196207
activeOpacity={1}
197208
onToggle={() => onToggleDestination(item)}
198209
state={isSetAsTerminus}
@@ -226,6 +237,7 @@ export const RouteInfoModal = ({
226237
wantedDestinationGroupId,
227238
onToggleNotification,
228239
onToggleDestination,
240+
isLEDTheme,
229241
]
230242
);
231243

src/components/SelectBoundModal.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const SelectBoundModal: React.FC<Props> = ({
176176
}
177177
}, [visible]);
178178

179-
// pendingStation が区間外の場合、stations 内の最寄り駅にフォールバック
179+
// pendingStation が区間外の場合、stations の先頭駅にフォールバック
180180
const effectiveStation =
181181
station && stations.some((s) => s.groupId === station.groupId)
182182
? station
@@ -567,8 +567,10 @@ export const SelectBoundModal: React.FC<Props> = ({
567567

568568
const handleToggleNotification = useCallback(
569569
(station: Station) => {
570+
if (station.id == null) return;
571+
572+
const stationId = station.id;
570573
setNotifyState((prev) => {
571-
const stationId = station.id ?? -1;
572574
const isEnabled = prev.targetStationIds.includes(stationId);
573575
return {
574576
...prev,
@@ -707,7 +709,7 @@ export const SelectBoundModal: React.FC<Props> = ({
707709
<Button
708710
outline
709711
onPress={() => setRouteInfoModalVisible(true)}
710-
disabled={loading}
712+
disabled={loading || isTransitioning}
711713
>
712714
{isBus
713715
? translate('viewBusStops')
@@ -717,7 +719,7 @@ export const SelectBoundModal: React.FC<Props> = ({
717719
<Button
718720
outline
719721
onPress={() => setIsTrainTypeModalVisible(true)}
720-
disabled={!fetchedTrainTypes.length || loading}
722+
disabled={!fetchedTrainTypes.length || loading || isTransitioning}
721723
>
722724
{trainTypeText}
723725
</Button>
@@ -727,7 +729,9 @@ export const SelectBoundModal: React.FC<Props> = ({
727729
style={savedRoute ? styles.redOutlinedButton : null}
728730
textStyle={savedRoute ? styles.redOutlinedButtonText : null}
729731
onPress={handleSaveRoutePress}
730-
disabled={!line || !isRoutesDBInitialized || loading}
732+
disabled={
733+
!line || !isRoutesDBInitialized || loading || isTransitioning
734+
}
731735
>
732736
{translate(
733737
!savedRoute ? 'saveCurrentRoute' : 'removeFromSavedRoutes'
@@ -736,6 +740,7 @@ export const SelectBoundModal: React.FC<Props> = ({
736740
<Button
737741
outline
738742
onPress={() => setSelectBoundSettingListModalVisible(true)}
743+
disabled={isTransitioning}
739744
>
740745
{translate('settings')}
741746
</Button>

src/hooks/usePresetCarouselData.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const usePresetCarouselData = (): UsePresetCarouselDataResult => {
1919
const [carouselData, setCarouselData] = useState<LoopItem[]>([]);
2020
const prevFetchKeyRef = useRef('');
2121
const prevDisplayKeyRef = useRef('');
22+
const currentRequestIdRef = useRef(0);
2223

2324
const {
2425
routes,
@@ -38,7 +39,7 @@ export const usePresetCarouselData = (): UsePresetCarouselDataResult => {
3839
const displayKey = routes
3940
.map(
4041
(r) =>
41-
`${r.id}:${r.lineId}:${r.trainTypeId}:${r.hasTrainType}:${r.name}:${r.direction}:${r.wantedDestinationId}`
42+
`${r.id}:${r.lineId}:${r.trainTypeId}:${r.hasTrainType}:${r.name}:${r.direction}:${r.wantedDestinationId}:${r.notifyStationIds.join(';')}`
4243
)
4344
.join(',');
4445

@@ -47,6 +48,8 @@ export const usePresetCarouselData = (): UsePresetCarouselDataResult => {
4748

4849
if (!needsFetch && !needsDisplayUpdate) return;
4950

51+
const requestId = ++currentRequestIdRef.current;
52+
5053
const fetchAsync = async () => {
5154
try {
5255
const lineStationsMap = new Map<number, Station[]>();
@@ -99,6 +102,7 @@ export const usePresetCarouselData = (): UsePresetCarouselDataResult => {
99102
}
100103
}
101104

105+
if (requestId !== currentRequestIdRef.current) return;
102106
prevFetchKeyRef.current = fetchKey;
103107
} else {
104108
// fetch不要の場合は既存のcarouselDataから駅データを再利用
@@ -111,6 +115,8 @@ export const usePresetCarouselData = (): UsePresetCarouselDataResult => {
111115
}
112116
}
113117

118+
if (requestId !== currentRequestIdRef.current) return;
119+
114120
setCarouselData(
115121
routes.map((r, i) => ({
116122
...r,

0 commit comments

Comments
 (0)