Skip to content

Add helper for reading and writing user preferences to localStorage #458

Description

@Chucks1093

Summary

User preferences such as preferred sort order on the creator list need to persist across page reloads. A shared localStorage helper with typed get and set functions should be the single place this read/write logic lives, avoiding raw localStorage calls scattered across components.

Scope

  • Add getPreference<T>(key: string, defaultValue: T): T and setPreference<T>(key: string, value: T): void helpers
  • Handle JSON serialization and deserialization internally
  • Return the defaultValue silently if the key is missing or JSON parsing fails
  • Add unit tests for: key present, key missing returns default, malformed JSON returns default

Acceptance Criteria

  • Returns stored value for a key that exists
  • Returns default value for a missing key
  • Returns default value if stored JSON is malformed
  • Set and get round-trip correctly

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions