diff --git a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt index 4c621c2..9a08b4e 100644 --- a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt +++ b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt @@ -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() diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/admin_screens/AdminLogsScreen.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/admin_screens/AdminLogsScreen.kt index 955451b..d2748cf 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/admin_screens/AdminLogsScreen.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/admin_screens/AdminLogsScreen.kt @@ -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(null) + } + + NotificationLogSync(controllers, refreshTrigger) { syncError = it } + + val shownError = errorMessage ?: syncError LaunchedEffect( selectedTab, @@ -264,7 +270,7 @@ private fun AdminLogsContent( } // Display an error message and retry button. - errorMessage != null -> { + shownError != null -> { Column( modifier = Modifier .fillMaxWidth() @@ -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++ } ) { @@ -344,7 +351,7 @@ private fun AdminLogsContent( } } - if (selectedTab == LogType.NOTIFICATION && errorMessage == null) { + if (selectedTab == LogType.NOTIFICATION && shownError == null) { LogPageControls(pager = notificationPages) } } diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt index 5b7e2ed..2663e64 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt @@ -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. @@ -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) } } }