From 7123d4b853dd8535aff3cbe859416c131c69ec18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AA=85=EC=84=9D?= Date: Thu, 2 Mar 2023 00:49:10 +0900 Subject: [PATCH] =?UTF-8?q?Issues=20#287=20feat:=20distinctUntilChanged=20?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=81=EC=9A=A9=ED=95=98=EC=97=AC=20=EB=8B=A4?= =?UTF-8?q?=EB=A5=B8=20=EA=B0=92=EC=97=90=20=EC=98=81=ED=96=A5=EC=9D=B4=20?= =?UTF-8?q?=EA=B0=80=EC=A7=80=20=EC=95=8A=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserPreferenceRepositoryImpl.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/data/data-preference/src/main/java/com/lighthouse/data/preference/repository/UserPreferenceRepositoryImpl.kt b/data/data-preference/src/main/java/com/lighthouse/data/preference/repository/UserPreferenceRepositoryImpl.kt index 05aa76812..f2c55c5b1 100644 --- a/data/data-preference/src/main/java/com/lighthouse/data/preference/repository/UserPreferenceRepositoryImpl.kt +++ b/data/data-preference/src/main/java/com/lighthouse/data/preference/repository/UserPreferenceRepositoryImpl.kt @@ -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 @@ -36,7 +37,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor( runCatchingPref { pref[loginUserUidKey] ?: "" } - } + }.distinctUntilChanged() } override suspend fun setEncryptData( @@ -63,7 +64,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor( val iv = pref[ivKey] ?: throw PrefNotFoundException("IV 값이 없습니다.") EncryptData(data, iv) } - } + }.distinctUntilChanged() } override suspend fun setSecurityOption( @@ -85,7 +86,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor( val value = pref[key] ?: throw PrefNotFoundException("Security 값이 없습니다.") SecurityOption.valueOf(value) } - } + }.distinctUntilChanged() } override suspend fun setNotificationEnable( @@ -98,7 +99,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor( override fun getNotificationEnable( userId: String ): Flow> { - return getBoolean(userId, KEY_NAME_NOTIFICATION_ENABLE) + return getBoolean(userId, KEY_NAME_NOTIFICATION_ENABLE).distinctUntilChanged() } override suspend fun setFilterExpired( @@ -109,7 +110,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor( } override fun getFilterExpired(userId: String): Flow> { - return getBoolean(userId, KEY_NAME_FILTER_EXPIRED) + return getBoolean(userId, KEY_NAME_FILTER_EXPIRED).distinctUntilChanged() } override suspend fun transferData( @@ -171,7 +172,7 @@ internal class UserPreferenceRepositoryImpl @Inject constructor( runCatchingPref { pref[key] ?: throw PrefNotFoundException("$keyName 값이 없습니다.") } - } + }.distinctUntilChanged() } companion object {