From d8c75e72e4882d3c740709624870c22dfbd6f8ec Mon Sep 17 00:00:00 2001 From: OneWay Date: Thu, 15 Oct 2026 13:45:00 +0800 Subject: [PATCH] fix(download): expire the sticky error state A download error stayed in the state flow forever: the dictionaries section replayed it as a snackbar on every recomposition and screens created later picked it up long after the failure, even while a newer download was already running. Error states now decay to idle after the same grace period as success, unless a newer state has replaced them. --- .../example/research/feature/download/DownloadManager.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/com/example/research/feature/download/DownloadManager.kt b/app/src/main/java/com/example/research/feature/download/DownloadManager.kt index fcde452..f7016a8 100644 --- a/app/src/main/java/com/example/research/feature/download/DownloadManager.kt +++ b/app/src/main/java/com/example/research/feature/download/DownloadManager.kt @@ -135,6 +135,10 @@ class DownloadManager( } } + delay(TERMINAL_STATE_DURATION) + if (downloadState.value is DownloadState.Error) { + updateDownloadProgressState(DownloadState.Idle, 0f) + } } } finally { downloadJob = null @@ -230,6 +234,10 @@ class DownloadManager( } } + delay(TERMINAL_STATE_DURATION) + if (downloadState.value is DownloadState.Error) { + updateDownloadProgressState(DownloadState.Idle, 0f) + } } } finally { downloadJob = null