summaryrefslogtreecommitdiffhomepage
path: root/android/app/src/main
diff options
context:
space:
mode:
authorKalle Lindström <karl.lindstrom@mullvad.net>2024-11-13 16:32:11 +0100
committerDavid Göransson <david.goransson@mullvad.net>2024-11-18 09:07:15 +0100
commit9e463290801047a80bd68b337c33040ff99f1828 (patch)
tree5e54b56944242bfe7f5d90ee8d524a109733001c /android/app/src/main
parenta75e50e64701835f263b1ba66133891781843a35 (diff)
downloadmullvadvpn-9e463290801047a80bd68b337c33040ff99f1828.tar.xz
mullvadvpn-9e463290801047a80bd68b337c33040ff99f1828.zip
Use ticker flow for Android system notifications
Diffstat (limited to 'android/app/src/main')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryInAppNotificationUseCase.kt15
1 files changed, 8 insertions, 7 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryInAppNotificationUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryInAppNotificationUseCase.kt
index 014f07bf35..057494f762 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryInAppNotificationUseCase.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryInAppNotificationUseCase.kt
@@ -9,7 +9,7 @@ import net.mullvad.mullvadvpn.lib.shared.AccountRepository
import net.mullvad.mullvadvpn.repository.InAppNotification
import net.mullvad.mullvadvpn.service.notifications.accountexpiry.ACCOUNT_EXPIRY_CLOSE_TO_EXPIRY_THRESHOLD
import net.mullvad.mullvadvpn.service.notifications.accountexpiry.ACCOUNT_EXPIRY_IN_APP_NOTIFICATION_UPDATE_INTERVAL
-import net.mullvad.mullvadvpn.service.notifications.accountexpiry.expiryTickerFlow
+import net.mullvad.mullvadvpn.service.notifications.accountexpiry.AccountExpiryTicker
class AccountExpiryInAppNotificationUseCase(private val accountRepository: AccountRepository) {
@@ -18,20 +18,21 @@ class AccountExpiryInAppNotificationUseCase(private val accountRepository: Accou
accountRepository.accountData
.flatMapLatest { accountData ->
if (accountData != null) {
- expiryTickerFlow(
+ AccountExpiryTicker.tickerFlow(
expiry = accountData.expiryDate,
tickStart = ACCOUNT_EXPIRY_CLOSE_TO_EXPIRY_THRESHOLD,
updateInterval = { ACCOUNT_EXPIRY_IN_APP_NOTIFICATION_UPDATE_INTERVAL },
)
- .map {
- it?.let { expiresInPeriod ->
- InAppNotification.AccountExpiry(expiresInPeriod)
+ .map { tick ->
+ when (tick) {
+ AccountExpiryTicker.NotWithinThreshold -> emptyList()
+ is AccountExpiryTicker.Tick ->
+ listOf(InAppNotification.AccountExpiry(tick.expiresIn))
}
}
} else {
- flowOf(null)
+ flowOf(emptyList())
}
}
- .map(::listOfNotNull)
.distinctUntilChanged()
}