diff options
Diffstat (limited to 'android/lib')
5 files changed, 18 insertions, 7 deletions
diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt index bac6e22277..f306c9f833 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/ManagementService.kt @@ -389,7 +389,9 @@ class ManagementService( suspend fun getAccountData( accountNumber: AccountNumber ): Either<GetAccountDataError, AccountData> = - Either.catch { grpc.getAccountData(StringValue.of(accountNumber.value)).toDomain() } + Either.catch { + grpc.getAccountData(StringValue.of(accountNumber.value)).toDomain(accountNumber) + } .onLeft { Logger.e("Get account data error") } .mapLeft(GetAccountDataError::Unknown) diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt index feb181f01d..f3037a8c1a 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt @@ -613,9 +613,10 @@ internal fun ManagementInterface.DeviceState.toDomain(): DeviceState = else -> throw NullPointerException("Device state is null") } -internal fun ManagementInterface.AccountData.toDomain(): AccountData = +internal fun ManagementInterface.AccountData.toDomain(accountNumber: AccountNumber): AccountData = AccountData( - AccountId(UUID.fromString(id)), + id = AccountId(UUID.fromString(id)), + accountNumber = accountNumber, expiryDate = Instant.ofEpochSecond(expiry.seconds).atDefaultZone(), ) diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/AccountData.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/AccountData.kt index b1746e1bcc..3c869ad3e0 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/AccountData.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/AccountData.kt @@ -2,4 +2,10 @@ package net.mullvad.mullvadvpn.lib.model import java.time.ZonedDateTime -data class AccountData(val id: AccountId, val expiryDate: ZonedDateTime) +data class AccountData( + val id: AccountId, + val accountNumber: AccountNumber, + val expiryDate: ZonedDateTime, +) { + companion object +} diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Notification.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Notification.kt index 6b073988a3..65805bb74e 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Notification.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Notification.kt @@ -17,7 +17,6 @@ sealed interface Notification { data class AccountExpiry( override val channelId: NotificationChannelId, override val actions: List<NotificationAction.AccountExpiry>, - val websiteAuthToken: WebsiteAuthToken?, val durationUntilExpiry: Duration, ) : Notification { override val ongoing: Boolean = false diff --git a/android/lib/shared/src/main/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepository.kt b/android/lib/shared/src/main/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepository.kt index a0edc2faa6..2e922a0895 100644 --- a/android/lib/shared/src/main/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepository.kt +++ b/android/lib/shared/src/main/kotlin/net/mullvad/mullvadvpn/lib/shared/AccountRepository.kt @@ -9,7 +9,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.stateIn @@ -41,7 +40,7 @@ class AccountRepository( val accountData: StateFlow<AccountData?> = merge( - managementService.deviceState.filterNotNull().map { deviceState -> + managementService.deviceState.map { deviceState -> when (deviceState) { is DeviceState.LoggedIn -> { managementService.getAccountData(deviceState.accountNumber).getOrNull() @@ -90,4 +89,8 @@ class AccountRepository( internal suspend fun onVoucherRedeemed(newExpiry: ZonedDateTime) { accountData.value?.copy(expiryDate = newExpiry)?.let { _mutableAccountDataCache.emit(it) } } + + fun resetIsNewAccount() { + _isNewAccount.value = false + } } |
