Repository navigation
位置情報関係のバグを修正 - #5273
位置情報関係のバグを修正#5273
Conversation
📝 WalkthroughWalkthroughStationSearchModalにモーダル専用の Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Modal as StationSearchModal
participant Location as fetchCurrentLocation
participant Store as Location Store
User->>Modal: Open modal
Note over Modal: modalVisible = true\n(first open)
Modal->>Location: fetchCurrentLocation()
Location-->>Modal: coords (lat,lng)
Modal->>Modal: set modalCoords
Modal->>Store: setLocation(coords)
Store-->>Modal: ack
User->>Modal: Close modal
Note over Modal: clear modalCoords
sequenceDiagram
participant Screen as SelectLineScreen
participant Props as Route Props\n(latitude/longitude)
participant Timer as Fallback Timer
participant Fetch as fetchInitialNearbyStationAsync
participant Result as Nearby Stations
Screen->>Screen: check initialNearbyFetchInFlightRef
alt coords provided via Props
Props->>Fetch: invoke with coords
else no coords
Screen->>Timer: start INITIAL_LOCATION_FALLBACK_DELAY_MS
Timer->>Fetch: invoke after delay
end
Fetch-->>Result: return stations / error
Screen->>Screen: reset initialNearbyFetchInFlightRef
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/StationSearchModal.tsx (1)
120-177:⚠️ Potential issue | 🟠 Majorモーダル非表示後の非同期操作による状態更新を抑止
fetchCurrentLocation()が非同期であり、モーダル閉鎖後に完了した場合、setModalCoordsとsetLocationが呼ばれて古い座標が再設定される競合状況が発生します。クリーンアップでactiveフラグを使用して、完了後の状態更新をガードしてください。🔧 修正案
useEffect(() => { + let active = true; if (!visible) { setModalCoords(null); wasVisibleRef.current = false; - return; + return () => { + active = false; + }; } if (wasVisibleRef.current) return; wasVisibleRef.current = true; const refreshLocation = async () => { try { const currentLocation = await fetchCurrentLocation(); + if (!active) return; setModalCoords({ latitude: currentLocation.coords.latitude, longitude: currentLocation.coords.longitude, }); setLocation(currentLocation); } catch (error) { - console.error(error); + if (active) { + console.error(error); + } } }; refreshLocation(); + return () => { + active = false; + }; }, [visible, fetchCurrentLocation]);
Summary by CodeRabbit
リリースノート