Skip to content

Commit

Permalink
[#159] Change back to simple flow to avoid mapping error unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
lydiasama committed Jan 12, 2023
1 parent 41c98c3 commit 48d57de
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package co.nimblehq.sample.compose.data.repository
import android.util.Log
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.*
import co.nimblehq.sample.compose.data.extensions.flowTransform
import co.nimblehq.sample.compose.domain.repository.AppPreferencesRepository
import kotlinx.coroutines.flow.*
import java.io.IOException
Expand All @@ -17,8 +16,8 @@ class AppPreferencesRepositoryImpl @Inject constructor(
val FIRST_TIME_LAUNCH = booleanPreferencesKey("FIRST_TIME_LAUNCH")
}

override fun getFirstTimeLaunchPreferences(): Flow<Boolean> = flowTransform {
appPreferencesDataStore.data
override fun getFirstTimeLaunchPreferences(): Flow<Boolean> = flow {
val firstLaunchPreferences = appPreferencesDataStore.data
.catch { exception ->
if (exception is IOException) {
Log.e(
Expand All @@ -33,6 +32,8 @@ class AppPreferencesRepositoryImpl @Inject constructor(
}.map { preferences ->
preferences[PreferencesKeys.FIRST_TIME_LAUNCH] ?: true
}.first()

emit(firstLaunchPreferences)
}

override suspend fun updateFirstTimeLaunchPreferences(isFirstTimeLaunch: Boolean) {
Expand Down

0 comments on commit 48d57de

Please sign in to comment.