Preferences Sync Across Devices
User preferences (notification toggles, language selection, and references to accessibility settings) are stored using a dual-storage strategy: locally in shared_preferences for immediate UI responsiveness, and remotely in the Supabase accessibility_preferences and theme_configs tables for cross-device consistency. The Preferences Service, implemented as a Riverpod async notifier, handles conflict resolution by treating Supabase as the authoritative source on first load after sign-in, then keeping both stores in sync on every subsequent change. If the remote load fails due to network issues, local preferences are applied as a fallback.
User Story
Acceptance Criteria
- Given I have configured notification preferences on device A, when I sign into the app on device B, then the same notification preferences are applied without manual reconfiguration
- Given the app loads after sign-in and the device is online, when preferences are fetched from Supabase, then the remote preferences take precedence over any locally cached values
- Given the app loads after sign-in and the device is offline, when the remote fetch fails, then locally cached preferences are applied and a background sync is scheduled for when connectivity is restored
- Given I change a preference while online, when the change is saved, then both local storage and Supabase are updated within the same write operation
- Given my account is deleted or I sign in as a different user, when the session changes, then all previously cached preferences are cleared before loading the new user's preferences
Business Value
Peer mentors and coordinators frequently switch between personal and work devices or reinstall the app after device upgrades. Without cross-device sync, accessibility settings critical for users with visual impairments would be lost on every reinstall, creating a significant barrier. Automatic sync reduces setup friction and support requests across all user roles.
Components
- Preferences Service service
- Preferences Repository data