Skip to content

Commit

Permalink
Migrate only privacy disclosure accepted key
Browse files Browse the repository at this point in the history
  • Loading branch information
kl committed Dec 18, 2024
1 parent 8c34ed0 commit ba91e19
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ private const val IS_PRIVACY_DISCLOSURE_ACCEPTED_KEY_SHARED_PREF_KEY =
data object UserPreferencesMigration {
fun migrations(context: Context): List<DataMigration<UserPreferences>> =
listOf(
SharedPreferencesMigration(context, sharedPreferencesName = APP_PREFERENCES_NAME) {
sharedPrefs: SharedPreferencesView,
currentData: UserPreferences ->
if (
SharedPreferencesMigration(
context,
sharedPreferencesName = APP_PREFERENCES_NAME,
keysToMigrate = setOf(IS_PRIVACY_DISCLOSURE_ACCEPTED_KEY_SHARED_PREF_KEY),
) { sharedPrefs: SharedPreferencesView, currentData: UserPreferences ->
val privacyDisclosureAccepted =
sharedPrefs.getBoolean(
IS_PRIVACY_DISCLOSURE_ACCEPTED_KEY_SHARED_PREF_KEY,
false,
)
) {
currentData.toBuilder().setIsPrivacyDisclosureAccepted(true).build()
} else {
currentData
}
currentData
.toBuilder()
.setIsPrivacyDisclosureAccepted(privacyDisclosureAccepted)
.build()
}
)
}

0 comments on commit ba91e19

Please sign in to comment.