Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements local storage persistence for user sharing preferences and refactors the private contact information handling. The changes enable user preferences to persist across app sessions using Android DataStore.
- Adds
UserSharePreferencesStorageinterface with DataStore implementation for persisting share preferences - Introduces new use cases for getting and updating user share preferences with Flow-based reactive updates
- Refactors private contact info handling by separating data model (
PrivateContactInfo) from UI state (PrivateContactState)
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| UpdateUserSharePreferencesUseCase.kt | New use case for updating user share preferences with storage persistence |
| GetUserSharePreferencesUseCase.kt | New use case for retrieving user share preferences as a Flow with distinct updates |
| UserSharePreferences.kt | Enhanced data model with private email/phone fields and default values |
| PrivateContactInfo.kt | New domain model for private contact information separate from UI state |
| UserComponentModule.kt | Dependency injection setup for new use cases |
| DatastoreModule.kt | DataStore configuration for UserSharePreferencesStorage |
| UserPrefsStorage.kt | DataStore implementation with preference keys and serialization logic |
| ShareViewModel.kt | Updated to use new use cases and handle preference persistence |
| ShareUiState.kt | Refactored to separate domain models from UI state representation |
| Various test files | Updated tests to use new models and default values |
| * Convenient interface to clear all user related data in one call. | ||
| */ | ||
| internal interface UserStorage : AuthTokenStorage, AvatarCacheBusterStorage { | ||
| internal interface UserStorage : AuthTokenStorage, AvatarCacheBusterStorage, UserSharePreferencesStorage { |
There was a problem hiding this comment.
The UserStorage interface is inheriting from UserSharePreferencesStorage, but the clear() method doesn't explicitly clear user share preferences. This could lead to inconsistent behavior where auth tokens and cache busters are cleared but share preferences persist.
homeUi/src/main/kotlin/com/gravatar/app/homeUi/presentation/home/share/ShareViewModel.kt
Show resolved
Hide resolved
homeUi/src/main/kotlin/com/gravatar/app/homeUi/presentation/home/share/ShareViewModel.kt
Show resolved
Hide resolved
c58098a to
f5c853f
Compare
|
|
||
| private val tokenKey = stringPreferencesKey(AUTH_TOKEN_KEY) | ||
| private val avatarCacheBusterKey = stringPreferencesKey(AVATAR_CACHE_BUSTER_KEY) | ||
| private val userShareNameKey = booleanPreferencesKey(USER_SHARE_NAME_KEY) |
There was a problem hiding this comment.
💡 This is growing fast. Not for this PR, but we may consider splitting it up.
# Conflicts: # homeUi/src/main/kotlin/com/gravatar/app/homeUi/presentation/home/share/components/SharePrivateContactInfo.kt
Description
This PR adds local storage for the
UserSharePreferences.Additionally (in the 2nd commit), I've remodeled a bit how the ShareUiState is built with the private contact info and added the private phone/email share prefs to the
UserSharePreferencesas well. The newPrivateContactInfofrom:userComponentshould be used in the next PRs to get/update those values.Testing Steps