Skip to content
Snippets Groups Projects
Verified Commit c6bc4bec authored by Mikolai Gütschow's avatar Mikolai Gütschow
Browse files

only show expiration banner 2 month before expiration

parent 2c12daf7
No related branches found
No related tags found
1 merge request!363only show expiration banner 2 month before expiration
Pipeline #15382 passed
/* /*
* Briar Desktop * Briar Desktop
* Copyright (C) 2021-2022 The Briar Project * Copyright (C) 2021-2023 The Briar Project
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -66,7 +66,7 @@ fun ColumnScope.ExpirationBanner(onExpired: () -> Unit) { ...@@ -66,7 +66,7 @@ fun ColumnScope.ExpirationBanner(onExpired: () -> Unit) {
var hideTimestamp by remember { mutableStateOf(0L) } var hideTimestamp by remember { mutableStateOf(0L) }
var showExpirationBanner by remember { mutableStateOf(value = true) } var showExpirationBanner by remember { mutableStateOf(false) }
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
periodicallyCheckIfExpired( periodicallyCheckIfExpired(
......
/* /*
* Briar Desktop * Briar Desktop
* Copyright (C) 2021-2022 The Briar Project * Copyright (C) 2021-2023 The Briar Project
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
...@@ -28,11 +28,13 @@ import kotlin.time.Duration.Companion.milliseconds ...@@ -28,11 +28,13 @@ import kotlin.time.Duration.Companion.milliseconds
object ExpirationUtils { object ExpirationUtils {
private val EXPIRE_AFTER = BuildData.GIT_TIME + 181.days.inWholeMilliseconds private val EXPIRE_AFTER = BuildData.GIT_TIME + 181.days.inWholeMilliseconds
private val SHOW_THRESHOLD = 60.days.inWholeMilliseconds
private val CHECK_INTERVAL = 1.hours.inWholeMilliseconds private val CHECK_INTERVAL = 1.hours.inWholeMilliseconds
private val HIDE_INTERVAL = 1.days.inWholeMilliseconds private val HIDE_INTERVAL = 1.days.inWholeMilliseconds
// for testing uncomment the following instead // for testing uncomment the following instead
// private val EXPIRE_AFTER = Instant.now().toEpochMilli() + 30.seconds.inWholeMilliseconds // private val EXPIRE_AFTER = Instant.now().toEpochMilli() + 30.seconds.inWholeMilliseconds
// private val SHOW_THRESHOLD = 10.seconds.inWholeMilliseconds
// private val CHECK_INTERVAL = 1.seconds.inWholeMilliseconds // private val CHECK_INTERVAL = 1.seconds.inWholeMilliseconds
// private val HIDE_INTERVAL = 10.seconds.inWholeMilliseconds // private val HIDE_INTERVAL = 10.seconds.inWholeMilliseconds
...@@ -42,6 +44,8 @@ object ExpirationUtils { ...@@ -42,6 +44,8 @@ object ExpirationUtils {
private fun isExpired() = getMillisLeft() <= 0.milliseconds private fun isExpired() = getMillisLeft() <= 0.milliseconds
private fun expiryIsFar() = getMillisLeft() > SHOW_THRESHOLD.milliseconds
private fun hideThreshold() = System.currentTimeMillis() - HIDE_INTERVAL private fun hideThreshold() = System.currentTimeMillis() - HIDE_INTERVAL
suspend fun periodicallyCheckIfExpired( suspend fun periodicallyCheckIfExpired(
...@@ -50,7 +54,9 @@ object ExpirationUtils { ...@@ -50,7 +54,9 @@ object ExpirationUtils {
onExpiry: () -> Unit, onExpiry: () -> Unit,
) { ) {
while (true) { while (true) {
if (isExpired()) { if (expiryIsFar()) {
// do nothing
} else if (isExpired()) {
onExpiry() onExpiry()
break break
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment