From 259b0128c96a4a93a22ec7387ff77dfc5103242b Mon Sep 17 00:00:00 2001 From: PTah Date: Wed, 10 Jun 2026 16:23:13 +1000 Subject: [PATCH] fix: compile errors for assembleDebug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Исправлены generic-типы в списках и import mutableStateOf в MainActivity. Co-authored-by: Cursor --- .../java/ru/kalinamall/seaca/MainActivity.kt | 1 + .../seaca/ui/screens/ListScreens.kt | 40 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/ru/kalinamall/seaca/MainActivity.kt b/app/src/main/java/ru/kalinamall/seaca/MainActivity.kt index fc96a87..e8bf179 100644 --- a/app/src/main/java/ru/kalinamall/seaca/MainActivity.kt +++ b/app/src/main/java/ru/kalinamall/seaca/MainActivity.kt @@ -24,6 +24,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf as composeMutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope diff --git a/app/src/main/java/ru/kalinamall/seaca/ui/screens/ListScreens.kt b/app/src/main/java/ru/kalinamall/seaca/ui/screens/ListScreens.kt index 347023d..da1f978 100644 --- a/app/src/main/java/ru/kalinamall/seaca/ui/screens/ListScreens.kt +++ b/app/src/main/java/ru/kalinamall/seaca/ui/screens/ListScreens.kt @@ -76,7 +76,10 @@ fun DashboardScreen(repo: SacRepository) { d.recentEvents.take(8).forEach { e -> Text("${e.severity} · ${e.title}", style = MaterialTheme.typography.bodySmall) } - } ?: if (loading) CircularProgressIndicator() + } + if (data == null && loading) { + CircularProgressIndicator() + } } } } @@ -97,9 +100,10 @@ fun EventsScreen(repo: SacRepository, onOpen: (Long) -> Unit) { PagedListScreen( title = "События", loadPage = { page, severity -> - repo.withAuth { it.listEvents(page = page, pageSize = 30, severity = severity) } + val res = repo.withAuth { it.listEvents(page = page, pageSize = 30, severity = severity) } + res.items to res.total }, - itemKey = { it.id }, + itemKey = EventSummary::id, itemLabel = { "${it.severity} · ${it.title}" }, itemSub = { "${it.hostname} · ${it.occurredAt}" }, onOpen = onOpen, @@ -113,11 +117,12 @@ fun ProblemsScreen(repo: SacRepository, onOpen: (Long) -> Unit) { PagedListScreen( title = "Проблемы", loadPage = { page, filter -> - repo.withAuth { + val res = repo.withAuth { it.listProblems(page = page, pageSize = 30, status = filter ?: "open") } + res.items to res.total }, - itemKey = { it.id }, + itemKey = ProblemSummary::id, itemLabel = { "${it.severity} · ${it.title}" }, itemSub = { "${it.status} · ${it.hostname ?: "—"}" }, onOpen = onOpen, @@ -131,9 +136,10 @@ fun HostsScreen(repo: SacRepository, onOpen: (Long) -> Unit) { PagedListScreen( title = "Хосты", loadPage = { page, _ -> - repo.withAuth { it.listHosts(page = page, pageSize = 30) } + val res = repo.withAuth { it.listHosts(page = page, pageSize = 30) } + res.items to res.total }, - itemKey = { it.id }, + itemKey = HostSummary::id, itemLabel = { it.hostname }, itemSub = { "${it.agentStatus} · ${it.product}" }, onOpen = onOpen, @@ -208,7 +214,7 @@ fun ReportsScreen(repo: SacRepository, onOpen: (Long) -> Unit) { @Composable private fun PagedListScreen( title: String, - loadPage: suspend (Int, String?) -> Any, + loadPage: suspend (Int, String?) -> Pair, Int>, itemKey: (T) -> Long, itemLabel: (T) -> String, itemSub: (T) -> String, @@ -228,21 +234,9 @@ private fun PagedListScreen( scope.launch { loading = true try { - @Suppress("UNCHECKED_CAST") - when (val res = loadPage(page, filter)) { - is EventListResponse -> { - items = res.items as List - total = res.total - } - is ProblemListResponse -> { - items = res.items as List - total = res.total - } - is HostListResponse -> { - items = res.items as List - total = res.total - } - } + val (pageItems, pageTotal) = loadPage(page, filter) + items = pageItems + total = pageTotal } catch (e: Exception) { error = e.message } finally {