Skip to content

Commit

Permalink
Issues boostcampwm-2022#287 feat: distinctUntilChanged 를 적용하여 다른 값에 영…
Browse files Browse the repository at this point in the history
…향이 가지 않게 변경
  • Loading branch information
audxo112 committed Mar 1, 2023
1 parent a50d005 commit 7123d4b
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.lighthouse.data.preference.ext.runCatchingPref
import com.lighthouse.data.preference.ext.stringKey
import com.lighthouse.repository.user.UserPreferenceRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import javax.inject.Inject
Expand All @@ -36,7 +37,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor(
runCatchingPref {
pref[loginUserUidKey] ?: ""
}
}
}.distinctUntilChanged()
}

override suspend fun setEncryptData(
Expand All @@ -63,7 +64,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor(
val iv = pref[ivKey] ?: throw PrefNotFoundException("IV 값이 없습니다.")
EncryptData(data, iv)
}
}
}.distinctUntilChanged()
}

override suspend fun setSecurityOption(
Expand All @@ -85,7 +86,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor(
val value = pref[key] ?: throw PrefNotFoundException("Security 값이 없습니다.")
SecurityOption.valueOf(value)
}
}
}.distinctUntilChanged()
}

override suspend fun setNotificationEnable(
Expand All @@ -98,7 +99,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor(
override fun getNotificationEnable(
userId: String
): Flow<Result<Boolean>> {
return getBoolean(userId, KEY_NAME_NOTIFICATION_ENABLE)
return getBoolean(userId, KEY_NAME_NOTIFICATION_ENABLE).distinctUntilChanged()
}

override suspend fun setFilterExpired(
Expand All @@ -109,7 +110,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor(
}

override fun getFilterExpired(userId: String): Flow<Result<Boolean>> {
return getBoolean(userId, KEY_NAME_FILTER_EXPIRED)
return getBoolean(userId, KEY_NAME_FILTER_EXPIRED).distinctUntilChanged()
}

override suspend fun transferData(
Expand Down Expand Up @@ -171,7 +172,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor(
runCatchingPref {
pref[key] ?: throw PrefNotFoundException("$keyName 값이 없습니다.")
}
}
}.distinctUntilChanged()
}

companion object {
Expand Down

0 comments on commit 7123d4b

Please sign in to comment.