refactor(auth): generalize clearLocalStorage with reusable utility#4925
refactor(auth): generalize clearLocalStorage with reusable utility#4925XyneSpaces wants to merge 1 commit into
Conversation
…earLocalStorageExcept() accepting getter/setter tuples, refactor clearLocalStorage() to use new utility, maintains backward compatibility (6 call sites unchanged), preserves: themeId, domain, customTableColumns Closes #2894
XyneSpaces
left a comment
There was a problem hiding this comment.
Review Summary
Classification: Refactoring — LocalStorage utility generalization
Risk Level: Low
Files Changed: 1 file (CommonAuthUtils.res)
Verification Against Control Center Checklist
Tier 1 — Naming Consistency:
✅ Function name clearLocalStorageExcept clearly indicates purpose (clear except specified keys)
✅ Parameter name keysToPreserve accurately describes the array of getter/setter tuples
✅ Follows existing camelCase convention for utility functions
Tier 2 — Reuse & Hygiene:
✅ Uses existing LocalStorage.clear() API correctly
✅ Leverages existing Array.map, Array.forEachWithIndex patterns
✅ Proper Option handling with Some(Some(value)) pattern
Tier 3 — Backward Compatibility:
✅ Original clearLocalStorage() function signature unchanged
✅ All 6 existing call sites remain functional
✅ Same keys preserved (themeId, domain, customTableColumns)
Findings
None. Clean refactoring that improves maintainability while preserving existing behavior.
Verdict: ✅ Approve — Well-structured utility extraction with no breaking changes.
Type of Change
Description
Replaced hardcoded
clearLocalStorageimplementation with a generalizedclearLocalStorageExceptutility that accepts getter/setter tuples for keys to preserve.Changes:
clearLocalStorageExcept()accepting array of(getter, setter)tuplesclearLocalStorage()to use new utilityMotivation and Context
Closes #2894
The previous implementation hardcoded specific keys (themeId, domain, customTableColumns) making it inflexible. The new utility allows any set of keys to be preserved, improving maintainability.
How did you test it?
npm run re:build(2,745 modules compiled successfully)npm run build(passed with expected size warnings)Where to test it?
Backend Dependency
Feature Flag
Checklist
npm run re:buildnpm run build