Skip to content

refactor(auth): generalize clearLocalStorage with reusable utility#4925

Open
XyneSpaces wants to merge 1 commit into
mainfrom
refactor/2894-generalize-clear-local-storage
Open

refactor(auth): generalize clearLocalStorage with reusable utility#4925
XyneSpaces wants to merge 1 commit into
mainfrom
refactor/2894-generalize-clear-local-storage

Conversation

@XyneSpaces

Copy link
Copy Markdown
Collaborator

Type of Change

  • Refactoring

Description

Replaced hardcoded clearLocalStorage implementation with a generalized clearLocalStorageExcept utility that accepts getter/setter tuples for keys to preserve.

Changes:

  • Added clearLocalStorageExcept() accepting array of (getter, setter) tuples
  • Refactored clearLocalStorage() to use new utility
  • Maintains backward compatibility — all 6 call sites unchanged
  • Preserves: themeId, domain, customTableColumns

Motivation 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?

  • ✅ ReScript build: npm run re:build (2,745 modules compiled successfully)
  • ✅ Production build: npm run build (passed with expected size warnings)
  • Manual verification: logout flow preserves theme/domain/table preferences

Where to test it?

  • INTEG
  • SANDBOX
  • PROD

Backend Dependency

  • No

Feature Flag

  • No feature flag changes

Checklist

  • I ran npm run re:build
  • I ran npm run build
  • Code follows existing patterns
  • No hardcoded values introduced
  • Backward compatible

…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 XyneSpaces requested a review from a team as a code owner June 5, 2026 09:48
@semanticdiff-com

Copy link
Copy Markdown

Review changes with  SemanticDiff

@github-actions github-actions Bot added the R-ready-for-review PR is ready for reviewing label Jun 5, 2026

@XyneSpaces XyneSpaces left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R-ready-for-review PR is ready for reviewing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Hardcoded clearLocalStorage Implementation

1 participant