The XHR interceptor baked _MOCK_TRAIN at page load time, so seeking or
advancing a playback frame only changed React state but had no effect
on the already-loaded WebView page.
- webviewXhrInterceptor.ts:
- Expose window.__jrsMockUpdateTrain(newData) from inside the IIFE so
the _MOCK_TRAIN variable can be updated after page load
- Add generateMockUpdateScript(trainPositions) helper: calls
__jrsMockUpdateTrain with fresh data + GetDateTime, then calls
window.setReload() to trigger the page's own redraw cycle
- WebView.tsx:
- Import generateMockUpdateScript
- Add useEffect watching mockTrainPositions (skips first mount since
beforeContentLoaded already has correct data)
- When mockApiFeatureEnabled && mockTrainPositions changes, inject the
update script via webview.current.injectJavaScript()
Result: seeking, prev/next frame, and auto-advance during playback now
immediately update the train position display in the WebView.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Crash fix (React Hooks violation):
- PlaybackTimeline.tsx: move ALL hooks (useRef for PanResponder, useCallback)
to before the early return; use seekRef/totalRef to share values into
PanResponder handlers without stale closure issues
Multiple recordings support:
- trainRecorder.ts: redesign to id-based multi-recording system
- RecordingMeta type for lightweight list (no snapshots)
- TrainRecording now includes id field
- saveRecording/loadRecordingById/deleteRecordingById/loadRecordingList
- migrateOldRecording() migrates old single MOCK_RECORDING key on first launch
- constants/storage.ts: add MOCK_RECORDINGS_INDEX + MOCK_RECORDING_DATA_PREFIX keys
- useTrainMenu: savedRecording → recordingList (RecordingMeta[]) + activeRecording (TrainRecording|null)
- startPlayback(id) loads full recording on demand
- deleteRecording(id) deletes by id and refreshes list
- stopPlayback clears activeRecording
- DataSourceSettings: recording list UI
- shows all recordings with date/time, snapshot count, duration
- ▶ play and 削除 buttons per row
- recording/playing status indicator
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- useTrainMenu: add playbackPaused state, pausePlayback/resumePlayback/seekToSnapshot
- playback loop now respects playbackPaused (no timer when paused)
- seekToSnapshot pauses playback and immediately applies snapshot data
- expose playbackIndex, playbackPaused + new functions in context value
- PlaybackTimeline.tsx: new component shown when recorderState === 'playing'
- absolute positioned bar at top of map screen (zIndex 2000)
- prev/play-pause/next frame buttons + skip-to-start/end
- time display (HH:mm:ss) + snapshot counter (n/total) + total duration
- PanResponder-based scrubber track with filled progress bar and draggable thumb
- Apps.tsx: render <PlaybackTimeline /> alongside FixedPositionBox
- Remove MockApiToggle.tsx (no longer used since settings-only toggle)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implements snapshot-based recording and playback of live train
position data for mock API debugging (admin-only).
Recording:
- startRecording() disables mock mode and begins capturing live
train snapshots every ~15s (via getCurrentTrain polling)
- Each snapshot stores { t: elapsed_ms, trains: TrainEntry[] }
- stopRecording() saves completed recording to AsyncStorage
Playback:
- startPlayback() enables mock mode and loops through snapshots
at their original recorded timing using useEffect+setTimeout
- stopPlayback() returns to idle
Storage:
- Single slot in AsyncStorage (MOCK_RECORDING key)
- Loaded on app start in useTrainMenu
- deleteRecording() removes it
New files:
- lib/mockApi/trainRecorder.ts — TrainRecording/TrainSnapshot types
+ save/load/delete AsyncStorage helpers
Modified files:
- constants/storage.ts — add MOCK_RECORDING key
- stateBox/useTrainMenu.tsx — recorder state + all controls
- stateBox/useCurrentTrain.tsx — call addTrainSnapshot after live fetch
- components/Settings/DataSourceSettings.tsx — record/play UI with
status dot, snapshot count, and action buttons
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The separate runtime MOCK switch on the map screen is removed.
Now the admin-only settings toggle (MOCK_API_FEATURE_ENABLED) is the
single control point — turning it on activates mock mode immediately,
turning it off deactivates it.
- useTrainMenu: remove mockApiEnabled/setMockApiEnabled state;
mockApiConfig now derives from mockApiFeatureEnabled alone
- WebView: use mockApiFeatureEnabled for key prop (triggers reload)
- Apps.tsx: remove MockApiToggle import and JSX usage
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- components/Apps/WebView.tsx:
- import mockApiEnabled from context
- add mockApiEnabled to WebView key so toggling forces a full reload
(injectedJavaScript only runs at page load, so reload is required)
- lib/mockApi/webviewXhrInterceptor.ts:
- Fix callback timing bug: callbacks set before open() were stored on
_orig (because _mockBody was null), never on self._onload, causing
mock send() to fire no-op callbacks
- Always store all callbacks/listeners in _callbacks/_listeners maps
- Apply _callbacks to _orig at send() time when not mocked
- Fix addEventListener: always buffer in _listeners, apply to _orig
at send() time; add removeEventListener support
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- constants/storage.ts: add MOCK_API_FEATURE_ENABLED key
- stateBox/useTrainMenu.tsx:
- import MOCK_TRAIN_POSITIONS; auto-populate on mount and on toggle-off
- add mockApiFeatureEnabled (persistent, admin-only) state + setter
- mockApiConfig now requires both mockApiFeatureEnabled AND mockApiEnabled
- components/Settings/DataSourceSettings.tsx:
- add mock API debug section (admin-gated, showDebugSelector)
- Switch toggles mockApiFeatureEnabled and persists to AsyncStorage
- components/Apps/MockApiToggle.tsx: new component
- absolute-positioned to the left of ReloadButton
- visible only when mockApiFeatureEnabled && mapSwitch==="true"
- MOCK label + Switch toggles mockApiEnabled runtime state
- components/Apps.tsx: render MockApiToggle alongside ReloadButton
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace measuredOffset (plain number) with animatedOffset (Animated.Value)
so the search bar smoothly follows the keyboard instead of jumping abruptly
- Wrap position:absolute container in Animated.View to accept Animated.Value as bottom
- Remove LayoutAnimation.configureNext calls that conflicted with Animated.timing
from useKeyboardAvoid, causing layout animation races on Android
- Drop unused keyboardHeight guard (keyboardHeight > 0 ? measuredBottom : 0);
animatedOffset starts at 0 and is driven by the hook's timing, so no jump
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>