Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,30 @@ class FilterPageUITest {
/**
* Taps the middle of the area map until an area is placed, since the map takes a moment to
* load before it reports taps.
*
* The map reports taps late on slow emulators, so it only taps again once a tap has had
* [MAP_TAP_WAIT_MS] to land. Tapping sooner can leave a late tap that places the area again
* after the test has moved on.
*/
private fun placeArea() {
composeTestRule.onNodeWithTag("areaMap").performScrollTo()
repeat(MAP_TAP_ATTEMPTS) {
composeTestRule.onNodeWithTag("areaMap").performTouchInput { click(center) }
composeTestRule.waitForIdle()
if (areaSummary().startsWith("Within")) return
Thread.sleep(MAP_TAP_WAIT_MS)
if (areaPlacedWithin(MAP_TAP_WAIT_MS)) return
}
throw AssertionError("Tapping the map never placed an area")
}

/**
* Waits up to [timeoutMs] for an area to be placed.
*
* @return `true` if the summary says an area is chosen before the time runs out.
*/
private fun areaPlacedWithin(timeoutMs: Long): Boolean =
runCatching {
composeTestRule.waitUntil(timeoutMs) { areaSummary().startsWith("Within") }
}.isSuccess

@Test
fun areaStartsUnchosen() {
composeTestRule.onNodeWithTag("areaSummary").performScrollTo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ private fun AdminLogsContent(
val notificationPages = controllers.adminLogs.notificationPages
val notificationSearch = if (selectedTab == LogType.NOTIFICATION) searchQuery else ""

NotificationLogSync(controllers, refreshTrigger) { errorMessage = it }
var syncError by remember {
mutableStateOf<String?>(null)
}

NotificationLogSync(controllers, refreshTrigger) { syncError = it }

val shownError = errorMessage ?: syncError

LaunchedEffect(
selectedTab,
Expand Down Expand Up @@ -264,7 +270,7 @@ private fun AdminLogsContent(
}

// Display an error message and retry button.
errorMessage != null -> {
shownError != null -> {
Column(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -274,13 +280,14 @@ private fun AdminLogsContent(
verticalArrangement = Arrangement.Center
) {
Text(
text = errorMessage.orEmpty(),
text = shownError.orEmpty(),
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodyMedium
)

TextButton(
onClick = {
syncError = null
refreshTrigger++
}
) {
Expand Down Expand Up @@ -344,7 +351,7 @@ private fun AdminLogsContent(
}
}

if (selectedTab == LogType.NOTIFICATION && errorMessage == null) {
if (selectedTab == LogType.NOTIFICATION && shownError == null) {
LogPageControls(pager = notificationPages)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ private fun GoogleAreaShape(area: SearchArea, color: Color) {

/**
* The Google version of [AreaMap]. The map frames the area once it loads, if one was already
* chosen, and the resize handle is drawn over it once it is ready.
* chosen. The resize handle is drawn over it as soon as the map is attached, which is when taps
* start working, without waiting for the tiles to finish loading.
*
* @param area The chosen area, or `null` if none is chosen yet.
* @param onAreaChange Called with the new area each time it is placed, moved or resized.
Expand Down Expand Up @@ -133,10 +134,8 @@ internal fun GoogleAreaMap(
}
area?.let { GoogleAreaShape(it, color) }
}
if (isLoaded) {
key(cameraPositionState.position) {
AreaResizeHandle(area, projector, onAreaChange)
}
key(cameraPositionState.position) {
AreaResizeHandle(area, projector, onAreaChange)
}
}
}