Updated on 2026-08-14

This commit is contained in:
Tangem 2024-11-25 14:50:39 +03:00
parent 299f10a1f6
commit 486f9a6c34
3 changed files with 31 additions and 1 deletions

View file

@ -10,6 +10,8 @@ import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.emptyPreferences
import androidx.datastore.preferences.preferencesDataStoreFile
import com.tangem.datasource.local.preferences.PreferencesDataStore.INSTANCE
import com.tangem.datasource.local.preferences.PreferencesKeys.APP_LOGS_KEY
import com.tangem.datasource.local.preferences.utils.CleanupKeyMigration
import com.tangem.datasource.local.preferences.utils.SharedPreferencesKeyMigration
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
@ -77,6 +79,7 @@ internal object PreferencesDataStore {
legacyKeyName = LEGACY_DEFAULT_KEY_NAME,
keyName = PreferencesKeys.BALANCE_HIDING_SETTINGS_KEY.name,
),
CleanupKeyMigration(key = APP_LOGS_KEY),
)
}
}

View file

@ -0,0 +1,18 @@
package com.tangem.datasource.local.preferences.utils
import androidx.datastore.core.DataMigration
import androidx.datastore.preferences.core.Preferences
internal class CleanupKeyMigration<T>(private val key: Preferences.Key<T>) : DataMigration<Preferences> {
override suspend fun cleanUp() {
// do nothing
}
override suspend fun shouldMigrate(currentData: Preferences): Boolean = currentData.contains(key)
override suspend fun migrate(currentData: Preferences): Preferences {
currentData.toMutablePreferences().remove(key)
return currentData
}
}