Skip to content

Commit

Permalink
Ensure AccountExpiryInAppNotification has initial emission
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 16, 2024
1 parent 029510a commit 90cbd8c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.mullvad.mullvadvpn.usecase

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import net.mullvad.mullvadvpn.lib.shared.AccountRepository
Expand All @@ -25,9 +26,10 @@ class AccountExpiryInAppNotificationUseCase(private val accountRepository: Accou
)
.map { expiresInPeriod -> InAppNotification.AccountExpiry(expiresInPeriod) }
} else {
emptyFlow<InAppNotification.AccountExpiry?>()
flowOf(null)
}
}
.onStart { emit(null) }
.map(::listOfNotNull)
.onStart { emit(emptyList()) }
.distinctUntilChanged()
}

0 comments on commit 90cbd8c

Please sign in to comment.