setUserProfile
Updates the user's profile information in preferences.
This function performs a transactional update to the user profile data, including user ID, name, and profile picture URI. The update is atomic and crash-safe.
When to Use
After successful authentication (store user session)
After profile updates from remote
When user edits their profile locally
Example
suspend fun saveUserProfile(user: User): Result<Unit> = suspendRunCatching {
val profile = PreferencesUserProfile(
id = user.id,
userName = user.name,
profilePictureUriString = user.avatarUrl
)
userPreferencesDataSource.setUserProfile(profile)
}Content copied to clipboard
Parameters
preferencesUserProfile
The user profile data to store.