Skip to content

Commit 651c7df

Browse files
committed
[BOOK-364] feat: 회원 탈퇴 시 Notification DataStore 초기화
1 parent c2d6c92 commit 651c7df

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.ninecraft.booket.core.data.impl.repository
22

33
import com.ninecraft.booket.core.common.utils.runSuspendCatching
44
import com.ninecraft.booket.core.data.api.repository.AuthRepository
5+
import com.ninecraft.booket.core.datastore.api.datasource.NotificationDataSource
56
import com.ninecraft.booket.core.datastore.api.datasource.TokenDataSource
67
import com.ninecraft.booket.core.model.AutoLoginState
78
import com.ninecraft.booket.core.model.UserState
@@ -15,6 +16,7 @@ private const val KAKAO_PROVIDER_TYPE = "KAKAO"
1516
internal class DefaultAuthRepository @Inject constructor(
1617
private val service: ReedService,
1718
private val tokenDataSource: TokenDataSource,
19+
private val notificationDataSource: NotificationDataSource,
1820
) : AuthRepository {
1921
override suspend fun login(accessToken: String) = runSuspendCatching {
2022
val response = service.login(
@@ -29,6 +31,7 @@ internal class DefaultAuthRepository @Inject constructor(
2931
override suspend fun logout() = runSuspendCatching {
3032
service.logout()
3133
clearTokens()
34+
clearNotificationDataStore()
3235
}
3336

3437
override suspend fun withdraw() = runSuspendCatching {
@@ -61,4 +64,8 @@ internal class DefaultAuthRepository @Inject constructor(
6164
val accessToken = tokenDataSource.getAccessToken()
6265
return if (accessToken.isBlank()) UserState.Guest else UserState.LoggedIn
6366
}
67+
68+
private suspend fun clearNotificationDataStore() {
69+
notificationDataSource.clearNotificationDataStore()
70+
}
6471
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ interface NotificationDataSource {
1111

1212
val lastSyncedNotificationEnabled: Flow<Boolean?>
1313
suspend fun setLastSyncedNotificationEnabled(isEnabled: Boolean)
14+
15+
suspend fun clearNotificationDataStore()
1416
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class DefaultNotificationDataSource @Inject constructor(
5151
}
5252
}
5353

54+
override suspend fun clearNotificationDataStore() {
55+
dataStore.edit { prefs ->
56+
prefs.clear()
57+
}
58+
}
59+
5460
companion object Companion {
5561
private val FCM_TOKEN = stringPreferencesKey("FCM_TOKEN")
5662
private val USER_NOTIFICATION_ENABLED = booleanPreferencesKey("USER_NOTIFICATION_ENABLED")

0 commit comments

Comments
 (0)