Skip to content

Commit 329d6dc

Browse files
committed
[BOOK-437] refactor: 서버 sync 시 로컬 FCM 값과 비교하는 로직 제거
1 parent 56bc9d2 commit 329d6dc

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

core/data/impl/src/main/kotlin/com/ninecraft/booket/core/data/impl/repository/DefaultUserRepository.kt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,11 @@ internal class DefaultUserRepository @Inject constructor(
4040

4141
override suspend fun syncFcmToken() = runSuspendCatching {
4242
val newToken = getRemoteFcmToken()
43-
val localToken = getLocalFcmToken()
44-
45-
if (newToken == localToken) {
46-
Logger.d("Skip FCM token sync (already up-to-date)")
47-
return@runSuspendCatching
48-
}
49-
5043
registerDevice(newToken)
51-
setFcmToken(newToken)
5244
}
5345

5446
override suspend fun syncFcmToken(fcmToken: String): Result<Unit> = runSuspendCatching {
5547
registerDevice(fcmToken)
56-
setFcmToken(fcmToken)
5748
}
5849

5950
override val isUserNotificationEnabled = notificationDataSource.isUserNotificationEnabled
@@ -93,11 +84,11 @@ internal class DefaultUserRepository @Inject constructor(
9384
}
9485
}
9586

96-
private suspend fun getLocalFcmToken(): String = notificationDataSource.fcmToken.first()
97-
98-
private suspend fun setFcmToken(fcmToken: String) {
99-
notificationDataSource.setFcmToken(fcmToken)
100-
}
87+
// private suspend fun getLocalFcmToken(): String = notificationDataSource.fcmToken.first()
88+
//
89+
// private suspend fun setFcmToken(fcmToken: String) {
90+
// notificationDataSource.setFcmToken(fcmToken)
91+
// }
10192

10293
private suspend fun getDeviceId(): String {
10394
return try {

core/datastore/api/src/main/kotlin/com/ninecraft/booket/core/datastore/api/datasource/NotificationDataSource.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ package com.ninecraft.booket.core.datastore.api.datasource
33
import kotlinx.coroutines.flow.Flow
44

55
interface NotificationDataSource {
6-
val fcmToken: Flow<String>
7-
suspend fun setFcmToken(fcmToken: String)
8-
96
val isUserNotificationEnabled: Flow<Boolean>
107
suspend fun setUserNotificationEnabled(isEnabled: Boolean)
118

core/datastore/impl/src/main/kotlin/com/ninecraft/booket/core/datastore/impl/datasource/DefaultNotificationDataSource.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import androidx.datastore.core.DataStore
44
import androidx.datastore.preferences.core.Preferences
55
import androidx.datastore.preferences.core.booleanPreferencesKey
66
import androidx.datastore.preferences.core.edit
7-
import androidx.datastore.preferences.core.stringPreferencesKey
87
import com.ninecraft.booket.core.datastore.api.datasource.NotificationDataSource
98
import com.ninecraft.booket.core.datastore.impl.di.NotificationDataStore
109
import com.ninecraft.booket.core.datastore.impl.util.handleIOException
@@ -15,18 +14,6 @@ import javax.inject.Inject
1514
class DefaultNotificationDataSource @Inject constructor(
1615
@NotificationDataStore private val dataStore: DataStore<Preferences>,
1716
) : NotificationDataSource {
18-
override val fcmToken: Flow<String> = dataStore.data
19-
.handleIOException()
20-
.map { prefs ->
21-
prefs[FCM_TOKEN] ?: ""
22-
}
23-
24-
override suspend fun setFcmToken(fcmToken: String) {
25-
dataStore.edit { prefs ->
26-
prefs[FCM_TOKEN] = fcmToken
27-
}
28-
}
29-
3017
override val isUserNotificationEnabled: Flow<Boolean> = dataStore.data
3118
.handleIOException()
3219
.map { prefs ->
@@ -58,7 +45,6 @@ class DefaultNotificationDataSource @Inject constructor(
5845
}
5946

6047
companion object Companion {
61-
private val FCM_TOKEN = stringPreferencesKey("FCM_TOKEN")
6248
private val USER_NOTIFICATION_ENABLED = booleanPreferencesKey("USER_NOTIFICATION_ENABLED")
6349
private val LAST_SYNCED_NOTIFICATION_ENABLED = booleanPreferencesKey("LAST_SYNCED_NOTIFICATION_ENABLED")
6450
}

0 commit comments

Comments
 (0)