-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eshc123
committed
Dec 22, 2024
1 parent
df7101d
commit 368116a
Showing
7 changed files
with
33 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
...rc/main/java/com/goalpanzi/mission_mate/core/domain/user/usecase/UpdateFcmTokenUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package com.goalpanzi.mission_mate.core.domain.user.usecase | ||
|
||
import com.goalpanzi.mission_mate.core.domain.user.repository.UserRepository | ||
import kotlinx.coroutines.flow.collect | ||
import kotlinx.coroutines.flow.firstOrNull | ||
import javax.inject.Inject | ||
|
||
class UpdateFcmTokenUseCase @Inject constructor( | ||
private val userRepository: UserRepository | ||
) { | ||
suspend operator fun invoke(fcmToken: String) = userRepository.updateFcmToken(fcmToken) | ||
suspend operator fun invoke(fcmToken: String) { | ||
val cachedFcmToken = userRepository.getCachedFcmToken().firstOrNull() | ||
if(fcmToken != cachedFcmToken){ | ||
userRepository.setCachedFcmToken(fcmToken).collect() | ||
userRepository.updateFcmToken(fcmToken) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters