Repository navigation
未使用スタイルの削除とListFooterやToast設定の再レンダリング対策 - #6421
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
📝 WalkthroughWalkthroughテーマ対応トーストを共通化し、複数設定画面のフッターをコンポーネント化した。あわせて、共通カード、路線表示、各種画面の未使用スタイルと依存するインポートを整理した。 ChangesUI更新とスタイル整理
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/GlobalToast.tsx (1)
40-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
ThemedBaseToastとThemedErrorToastの重複ロジックをファクトリ関数へ統合可能。対象コンポーネント(
BaseToast/ErrorToast)以外は完全に同一の実装です。1つのファクトリ関数に切り出すと保守性が向上します。♻️ 提案するリファクタ例
-const ThemedBaseToast: React.FC<ThemedToastProps> = ({ - ledColor, - defaultColor, - ...props -}) => { - const { style, text1Style, text2Style } = useToastStyles( - ledColor, - defaultColor - ); - - return ( - <BaseToast - {...props} - style={style} - contentContainerStyle={contentContainerStyle} - text1Style={text1Style} - text2Style={text2Style} - /> - ); -}; - -const ThemedErrorToast: React.FC<ThemedToastProps> = ({ - ledColor, - defaultColor, - ...props -}) => { - const { style, text1Style, text2Style } = useToastStyles( - ledColor, - defaultColor - ); - - return ( - <ErrorToast - {...props} - style={style} - contentContainerStyle={contentContainerStyle} - text1Style={text1Style} - text2Style={text2Style} - /> - ); -}; +const createThemedToast = ( + ToastComponent: typeof BaseToast | typeof ErrorToast +): React.FC<ThemedToastProps> => { + const ThemedToast: React.FC<ThemedToastProps> = ({ + ledColor, + defaultColor, + ...props + }) => { + const { style, text1Style, text2Style } = useToastStyles( + ledColor, + defaultColor + ); + + return ( + <ToastComponent + {...props} + style={style} + contentContainerStyle={contentContainerStyle} + text1Style={text1Style} + text2Style={text2Style} + /> + ); + }; + return ThemedToast; +}; + +const ThemedBaseToast = createThemedToast(BaseToast); +const ThemedErrorToast = createThemedToast(ErrorToast);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/GlobalToast.tsx` around lines 40 - 85, ThemedBaseToast and ThemedErrorToast duplicate the same styling and prop-forwarding logic. Extract their shared implementation into a factory function parameterized by the target toast component, then create each themed toast from that factory while preserving the existing ledColor, defaultColor, and style behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/components/GlobalToast.tsx`:
- Around line 40-85: ThemedBaseToast and ThemedErrorToast duplicate the same
styling and prop-forwarding logic. Extract their shared implementation into a
factory function parameterized by the target toast component, then create each
themed toast from that factory while preserving the existing ledColor,
defaultColor, and style behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f7b6597d-fc67-4773-ad65-c9c3b9e2116f
📒 Files selected for processing (22)
src/components/CommonCard.tsxsrc/components/GlobalToast.tsxsrc/components/LineBoard.tsxsrc/components/LineBoardE231.tsxsrc/components/LineBoardSaikyo.tsxsrc/components/NowHeader.tsxsrc/components/NumberingIconHalfSquare.tsxsrc/components/NumberingIconReversedRound.tsxsrc/components/NumberingNishitetsu.tsxsrc/components/PresetCard.tsxsrc/components/RouteInfoModal.tsxsrc/components/SelectBoundModal.tsxsrc/components/SettingsHeader.tsxsrc/components/StationSearchModal.tsxsrc/components/TrainTypeBoxJRKyushu.tsxsrc/components/TransferLineMark.tsxsrc/components/TypeChangeNotify.tsxsrc/screens/EnabledLanguagesSettings.tsxsrc/screens/Licenses.tsxsrc/screens/Privacy.tsxsrc/screens/TTSSettings.tsxsrc/screens/ThemeSettings.tsx
💤 Files with no reviewable changes (14)
- src/components/TransferLineMark.tsx
- src/components/SettingsHeader.tsx
- src/screens/Privacy.tsx
- src/components/TypeChangeNotify.tsx
- src/components/NumberingNishitetsu.tsx
- src/components/StationSearchModal.tsx
- src/components/NowHeader.tsx
- src/components/SelectBoundModal.tsx
- src/components/PresetCard.tsx
- src/components/TrainTypeBoxJRKyushu.tsx
- src/components/NumberingIconHalfSquare.tsx
- src/components/NumberingIconReversedRound.tsx
- src/components/RouteInfoModal.tsx
- src/components/LineBoard.tsx
5 of 9 tasks
4 of 9 tasks
5 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
未使用コードの削除と、レンダリングのたびにコンポーネントや設定オブジェクトが再生成されていた箇所の整理。アプリの見た目・挙動は変えないリファクタリングです。
変更の種類
変更内容
RFValue/Platformなど)を削除GlobalToast: 毎レンダーuseMemoで toastConfig を組み立てる構成をやめ、モジュールレベルの静的 config とテーマ対応のThemedBaseToast/ThemedErrorToastに分割EnabledLanguagesSettings/Licenses/TTSSettings/ThemeSettings:ListFooterComponentに渡していたインライン関数コンポーネントを独立したListFooterに切り出し、要素として渡すことでレンダリングごとの再マウントを抑止CommonCard:stationsのデフォルト値を毎レンダー新規生成される[]からモジュールレベルのEMPTY_STATIONSに変更し、参照を安定化テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
新機能
改善