fix: compile errors for assembleDebug

Исправлены generic-типы в списках и import mutableStateOf в MainActivity.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PTah
2026-06-10 16:23:13 +10:00
parent 23eb1ba64c
commit 259b0128c9
2 changed files with 18 additions and 23 deletions
@@ -24,6 +24,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableStateOf as composeMutableStateOf import androidx.compose.runtime.mutableStateOf as composeMutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
@@ -76,7 +76,10 @@ fun DashboardScreen(repo: SacRepository) {
d.recentEvents.take(8).forEach { e -> d.recentEvents.take(8).forEach { e ->
Text("${e.severity} · ${e.title}", style = MaterialTheme.typography.bodySmall) 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( PagedListScreen(
title = "События", title = "События",
loadPage = { page, severity -> 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}" }, itemLabel = { "${it.severity} · ${it.title}" },
itemSub = { "${it.hostname} · ${it.occurredAt}" }, itemSub = { "${it.hostname} · ${it.occurredAt}" },
onOpen = onOpen, onOpen = onOpen,
@@ -113,11 +117,12 @@ fun ProblemsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
PagedListScreen( PagedListScreen(
title = "Проблемы", title = "Проблемы",
loadPage = { page, filter -> loadPage = { page, filter ->
repo.withAuth { val res = repo.withAuth {
it.listProblems(page = page, pageSize = 30, status = filter ?: "open") 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}" }, itemLabel = { "${it.severity} · ${it.title}" },
itemSub = { "${it.status} · ${it.hostname ?: "—"}" }, itemSub = { "${it.status} · ${it.hostname ?: "—"}" },
onOpen = onOpen, onOpen = onOpen,
@@ -131,9 +136,10 @@ fun HostsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
PagedListScreen( PagedListScreen(
title = "Хосты", title = "Хосты",
loadPage = { page, _ -> 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 }, itemLabel = { it.hostname },
itemSub = { "${it.agentStatus} · ${it.product}" }, itemSub = { "${it.agentStatus} · ${it.product}" },
onOpen = onOpen, onOpen = onOpen,
@@ -208,7 +214,7 @@ fun ReportsScreen(repo: SacRepository, onOpen: (Long) -> Unit) {
@Composable @Composable
private fun <T> PagedListScreen( private fun <T> PagedListScreen(
title: String, title: String,
loadPage: suspend (Int, String?) -> Any, loadPage: suspend (Int, String?) -> Pair<List<T>, Int>,
itemKey: (T) -> Long, itemKey: (T) -> Long,
itemLabel: (T) -> String, itemLabel: (T) -> String,
itemSub: (T) -> String, itemSub: (T) -> String,
@@ -228,21 +234,9 @@ private fun <T> PagedListScreen(
scope.launch { scope.launch {
loading = true loading = true
try { try {
@Suppress("UNCHECKED_CAST") val (pageItems, pageTotal) = loadPage(page, filter)
when (val res = loadPage(page, filter)) { items = pageItems
is EventListResponse -> { total = pageTotal
items = res.items as List<T>
total = res.total
}
is ProblemListResponse -> {
items = res.items as List<T>
total = res.total
}
is HostListResponse -> {
items = res.items as List<T>
total = res.total
}
}
} catch (e: Exception) { } catch (e: Exception) {
error = e.message error = e.message
} finally { } finally {