Skip to content

Commit

Permalink
Merge pull request #94 from CrisisCleanup/update-incidents
Browse files Browse the repository at this point in the history
Update incidents
  • Loading branch information
hueachilles authored Sep 26, 2023
2 parents 02f1fe4 + f85010c commit a049ad1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {

android {
defaultConfig {
val buildVersion = 157
val buildVersion = 166
applicationId = "com.crisiscleanup"
versionCode = buildVersion
versionName = "0.8.${buildVersion - 155}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ data class SyncAttempt(
return false
}

val intervalSeconds = backoffIntervalSeconds.coerceAtLeast(1)
val deltaSeconds = (nowSeconds - attemptedSeconds).coerceAtLeast(1)
if (deltaSeconds > 3600) {
return false
}

val intervalSeconds = backoffIntervalSeconds.coerceAtLeast(1)
// now < attempted + interval * 2^(tries-1)
val lhs = ln(deltaSeconds / intervalSeconds.toFloat())
val rhs = (attemptedCounter - 1) * ln(2f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ class SyncAttemptTest {
assertFalse(syncAttempt.isBackingOff(0, 108))
}

@Test
fun backoffIntervalMaximum() {
val syncAttempt = SyncAttempt(10, 100, 11)

assertTrue(syncAttempt.isBackingOff(15, 100 + 3600))
assertFalse(syncAttempt.isBackingOff(15, 100 + 3601))
}

@Test
fun shouldSyncPassively() {
// Not recent, not backing off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private interface DataSourceApi {
fields: String,
@Query("limit")
limit: Int,
@Query("ordering")
@Query("sort")
ordering: String,
@Query("start_at__gt")
after: Instant?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -447,6 +448,16 @@ private fun ColumnScope.ExistingCaseContent(
}
BusyIndicatorFloatingTopCenter(isLoading)
}

val closeKeyboard = rememberCloseKeyboard(pagerState)
val pagerPage by remember(pagerState) {
derivedStateOf {
pagerState.currentPage
}
}
LaunchedEffect(pagerPage) {
closeKeyboard()
}
}

@Composable
Expand Down Expand Up @@ -1106,7 +1117,7 @@ internal fun EditExistingCaseNotesView(
}
},
modifier = Modifier.testTag("viewCaseAddNoteAction"),
enabled = isEditable && isScrolledDown,
enabled = isScrolledDown,
) {
Icon(
imageVector = CrisisCleanupIcons.CaretUp,
Expand Down

0 comments on commit a049ad1

Please sign in to comment.