From 1a360f97174f6d2e22a0a4eea3c5e187e348a562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Tue, 17 Oct 2023 12:43:48 +0200 Subject: [PATCH] Fix remarks --- .../component/notificationbanner/NotificationBanner.kt | 2 +- .../net/mullvad/mullvadvpn/constant/AccountExpiryConstant.kt | 1 + .../mullvadvpn/usecase/AccountExpiryNotificationUseCase.kt | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt index a1103a94ac64..af45e1c37ffb 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/notificationbanner/NotificationBanner.kt @@ -86,8 +86,8 @@ fun NotificationBanner( onClickShowAccount: () -> Unit, onClickDismissNewDevice: () -> Unit ) { + // Fix for animating to invisible state val previous = rememberPrevious(current = notification, shouldUpdate = { _, _ -> true }) - // Fix for animating t hide AnimatedVisibility( visible = notification != null, enter = slideInVertically(initialOffsetY = { -it }), diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/AccountExpiryConstant.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/AccountExpiryConstant.kt index dff48b6228f8..f22469a3dca1 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/AccountExpiryConstant.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/constant/AccountExpiryConstant.kt @@ -1,3 +1,4 @@ package net.mullvad.mullvadvpn.constant const val ACCOUNT_EXPIRY_POLL_INTERVAL: Long = 15 /* s */ * 1000 /* ms */ +const val ACCOUNT_EXPIRY_CLOSE_TO_EXPIRY_THRESHOLD_DAYS = 3 \ No newline at end of file diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryNotificationUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryNotificationUseCase.kt index 72ee15785499..e4d0071e0554 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryNotificationUseCase.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/AccountExpiryNotificationUseCase.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map +import net.mullvad.mullvadvpn.constant.ACCOUNT_EXPIRY_CLOSE_TO_EXPIRY_THRESHOLD_DAYS import net.mullvad.mullvadvpn.model.AccountExpiry import net.mullvad.mullvadvpn.repository.InAppNotification import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager @@ -28,7 +29,8 @@ class AccountExpiryNotificationUseCase( } else null private fun AccountExpiry.isCloseToExpiring(): Boolean { - val threeDaysFromNow = DateTime.now().plusDays(3) + val threeDaysFromNow = + DateTime.now().plusDays(ACCOUNT_EXPIRY_CLOSE_TO_EXPIRY_THRESHOLD_DAYS) return this.date()?.isBefore(threeDaysFromNow) == true } }