diff --git a/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt b/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt index e78ad11..a73f5e5 100644 --- a/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt +++ b/app-phone/src/main/kotlin/pw/binom/viewmate/phone/ui/DetailsScreen.kt @@ -85,34 +85,10 @@ fun DetailsScreen( mirrorStatus = runCatching { app.mirror.mirrorByItem(item.Id) }.getOrNull() mirrorJob = runCatching { app.mirror.list(limit = 500).firstOrNull { it.itemId == item.Id } }.getOrNull() loading = false - var retryCount = 0 - while (true) { - when (mirrorStatus?.status) { - "processing", "queued" -> { - delay(3_000) - mirrorStatus = runCatching { app.mirror.mirrorByItem(item.Id) }.getOrNull() - mirrorJob = runCatching { app.mirror.list(limit = 500).firstOrNull { it.itemId == item.Id } }.getOrNull() - retryCount = 0 - } - "done" -> { - break - } - "failed", "error" -> { - if (retryCount < 2) { - retryCount++ - log("mirror", "конвертация упала, retry $retryCount/2 для ${item.Id}") - runCatching { app.mirror.createMirror(item.Id) } - .onSuccess { refreshKey++ } - .onFailure { e -> log("mirror", "retry $retryCount не удался: ${e.message}") } - delay(5_000) - } else { - break - } - } - else -> { - break - } - } + while (mirrorStatus?.status == "processing" || mirrorStatus?.status == "queued") { + delay(3_000) + mirrorStatus = runCatching { app.mirror.mirrorByItem(item.Id) }.getOrNull() + mirrorJob = runCatching { app.mirror.list(limit = 500).firstOrNull { it.itemId == item.Id } }.getOrNull() } }