Persist tuning settings to AsyncStorage#5587
Conversation
📝 WalkthroughWalkthroughAsyncStorageキーの4つの新しい定数を定義し、アプリケーション起動時とユーザー設定変更時にそれらの値を読み取り・永続化する機能を追加。ヘッダーとボトム遷移のアニメーション制御とuntouchableモード設定に対応。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/TuningSettings.tsx (1)
144-177: AsyncStorage操作のエラーハンドリングを検討してください。
AsyncStorage.setItemがfire-and-forgetパターンで呼び出されており、永続化に失敗した場合、状態は更新されますがストレージには反映されません。Permitted.tsx(248-263行目)では同様の操作でtry/catchとロールバックが実装されています。この既存パターン(
handleEnVoiceNameChange等)に合わせているのは理解していますが、一貫性のためエラーハンドリングの追加を検討いただけますでしょうか。♻️ エラーハンドリング追加の提案例
const handleHeaderIntervalChange = (text: string) => { + const prevValue = settings.headerTransitionInterval; const value = parseNumberFromText(settings.headerTransitionInterval, text); setSettings((prev) => ({ ...prev, headerTransitionInterval: value, })); - AsyncStorage.setItem( - ASYNC_STORAGE_KEYS.HEADER_TRANSITION_INTERVAL, - String(value) - ); + AsyncStorage.setItem( + ASYNC_STORAGE_KEYS.HEADER_TRANSITION_INTERVAL, + String(value) + ).catch((error) => { + console.error(error); + setSettings((prev) => ({ + ...prev, + headerTransitionInterval: prevValue, + })); + }); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/TuningSettings.tsx` around lines 144 - 177, The three handlers (handleHeaderIntervalChange, handleHeaderDelayChange, handleBottomDelayChange) call AsyncStorage.setItem fire-and-forget; update them to mirror the pattern used in Permitted.tsx (e.g., handleEnVoiceNameChange): wrap the AsyncStorage.setItem call in try/catch, attempt to persist the new value derived via parseNumberFromText and ASYNC_STORAGE_KEYS, and on failure log the error and rollback the in-memory state to the previous value (use the prev state captured before setSettings) so UI state and storage remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/TuningSettings.tsx`:
- Around line 144-177: The three handlers (handleHeaderIntervalChange,
handleHeaderDelayChange, handleBottomDelayChange) call AsyncStorage.setItem
fire-and-forget; update them to mirror the pattern used in Permitted.tsx (e.g.,
handleEnVoiceNameChange): wrap the AsyncStorage.setItem call in try/catch,
attempt to persist the new value derived via parseNumberFromText and
ASYNC_STORAGE_KEYS, and on failure log the error and rollback the in-memory
state to the previous value (use the prev state captured before setSettings) so
UI state and storage remain consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1b7cc94b-7ea6-4c0d-857d-b640b26ce7f5
📒 Files selected for processing (3)
src/components/Permitted.tsxsrc/components/TuningSettings.tsxsrc/constants/asyncStorage.ts
Summary
This PR adds persistence for tuning settings to AsyncStorage, ensuring that user preferences for header/bottom transition intervals and delays, as well as developer overlay and untouchable mode settings, are retained across app sessions.
Key Changes
TuningSettings.tsx: Modified handler functions to persist setting changes to AsyncStorage immediately when values change
handleHeaderIntervalChange,handleHeaderDelayChange, andhandleBottomDelayChangenow save values to AsyncStoragetoggleDevOverlayEnabledandtoggleUntouchableModeEnablednow persist their statetoggleTelemetryEnabledsimplified to always persist changes (removed conditional alert logic)Permitted.tsx: Added initialization logic to restore persisted tuning settings from AsyncStorage on app startup
headerTransitionInterval,headerTransitionDelay,bottomTransitionInterval, anduntouchableModeEnabledasyncStorage.ts: Added four new AsyncStorage keys for the tuning settings
HEADER_TRANSITION_INTERVALHEADER_TRANSITION_DELAYBOTTOM_TRANSITION_INTERVALUNTOUCHABLE_MODE_ENABLEDImplementation Details
https://claude.ai/code/session_01JR8c8hRFxj73aLTZkFHmcR
Summary by CodeRabbit
リリースノート
新機能
改善