fix: reduce duplication when using useOverrideOpHelper for simple objects#1619
fix: reduce duplication when using useOverrideOpHelper for simple objects#1619Julusian wants to merge 2 commits intoSofie-Automation:mainfrom
Conversation
WalkthroughRefactors the UI Settings components to centralize override-handling logic into a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/webui/src/client/ui/Settings/util/OverrideOpHelper.tsx`:
- Line 13: The import for literal at the top of OverrideOpHelper.tsx uses the
source path ('@sofie-automation/corelib/src/lib') which is inconsistent with the
other imports; update that import to use the compiled module path
('@sofie-automation/corelib/dist/lib') so it matches the other imports in this
file and avoids bundler/resolution issues—modify the import statement that
references literal accordingly.
packages/webui/src/client/ui/Settings/util/OverrideOpHelper.tsx
Outdated
Show resolved
Hide resolved
2065514 to
f379959
Compare
About the Contributor
This pull request is posted on behalf of Superfly
Type of Contribution
This is a: Code improvement
Current Behavior
There is some duplicated logic/'hack' aroung using
useOverrideOpHelperfor a simple object (not aRecord<string, T>)This tidies it up by creating a new helper to handle this complexity in one place and avoid it being repeated everywhere
Testing
Affected areas
Time Frame
Other Information
Status
Summary
This PR reduces code duplication across the settings UI by introducing a new helper function
useOverrideOpHelperForSimpleObjectthat centralizes the handling of override operations for simple objects (non-Record types).Changes
New Helper (packages/webui/src/client/ui/Settings/util/OverrideOpHelper.tsx)
useOverrideOpHelperForSimpleObject<T>()that encapsulates the pattern of:applyAndValidateOverridesRefactored Components
useOverrideOpHelperForSimpleObject, eliminating intermediatewrappedItem,wrappedConfigObject, and prefixed path handlingStudioSettingsby replacing multi-step memo-based wrapping withuseOverrideOpHelperForSimpleObjectcallObjectWithOverridesgeneric onuseMemocalls to strengthen type safetyImpact
Files Changed