-
Notifications
You must be signed in to change notification settings - Fork 67
refactor: Extract determine current overlay logic to a utility function #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Extract determine current overlay logic to a utility function #167
Conversation
This commit extracts the duplicated logic for determining the current overlay ID into a separate utility function. The same logic was previously duplicated in both 'CLOSE' and 'REMOVE' reducer cases. This refactoring improves code maintainability and reduces the risk of inconsistent behavior between these operations. - Create overlay-utils.ts with determineCurrentOverlayId function - Update reducer.ts to use the new utility function - Add unit tests for the extracted function
🦋 Changeset detectedLatest commit: 2847229 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #167 +/- ##
==========================================
+ Coverage 93.87% 94.15% +0.27%
==========================================
Files 12 12
Lines 343 342 -1
Branches 85 83 -2
==========================================
Hits 322 322
+ Misses 20 19 -1
Partials 1 1
🚀 New features to boost your workflow:
|
jungpaeng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion.
Currently, the determineCurrentOverlayId function is only being used inside the reducer, and it doesn’t seem likely that it will be used outside of it. Could you move it to the reducer.ts file?
|
I made the change as requested. |
jungpaeng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Description
Refactors the duplicated logic for determining the current overlay ID into a separate utility function. This change improves code maintainability and reduces the risk of inconsistent behavior between the 'CLOSE' and 'REMOVE' operations.
Changes
determineCurrentOverlayIdfunctionMotivation and Context
While reviewing the code, I noticed that the same complex logic for determining which overlay should be active after closing or removing an overlay was duplicated in two places. This duplication makes it harder to maintain the code and increases the risk of inconsistent behavior if one implementation is updated but not the other.
How Has This Been Tested?
Types of changes
Checklist
Note to Maintainers
I considered a few options for where to place the extracted utility function
overlay-utils.tsfile in thecontextdirectory since it's closely related to overlay state managementreducer.tsas a private function (but would limit reusability)utilsdirectory if it might be used more broadly in the futureI'm open to suggestions if you prefer a different location or naming convention for this utility function.