Compare commits
6
Commits
9c76ebe3ff
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
692fb2117e | ||
|
|
3bb4e09b04 | ||
|
|
ff4ba62bbd | ||
|
|
123615e1f8 | ||
|
|
6889dd2c45 | ||
|
|
f22028d126 |
No files matched your search
@@ -52,6 +52,13 @@ class DownloadManager(
|
|||||||
var onDownloadSuccess: (() -> Unit)? = null
|
var onDownloadSuccess: (() -> Unit)? = null
|
||||||
var onTerminal: ((DownloadState) -> Unit)? = null
|
var onTerminal: ((DownloadState) -> Unit)? = null
|
||||||
|
|
||||||
|
private suspend fun expireErrorStateToIdle() {
|
||||||
|
delay(TERMINAL_STATE_DURATION)
|
||||||
|
if (downloadState.value is DownloadState.Error) {
|
||||||
|
updateDownloadProgressState(DownloadState.Idle, 0f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun startDownload() {
|
fun startDownload() {
|
||||||
if (downloadState.value is DownloadState.Loading) return
|
if (downloadState.value is DownloadState.Loading) return
|
||||||
if (!downloadScope.isActive) return
|
if (!downloadScope.isActive) return
|
||||||
@@ -79,6 +86,7 @@ class DownloadManager(
|
|||||||
updateDownloadProgressState(
|
updateDownloadProgressState(
|
||||||
DownloadState.Error(sourceUnavailableMessage), 0f
|
DownloadState.Error(sourceUnavailableMessage), 0f
|
||||||
)
|
)
|
||||||
|
expireErrorStateToIdle()
|
||||||
return@withLock
|
return@withLock
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +143,7 @@ class DownloadManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
expireErrorStateToIdle()
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
downloadJob = null
|
downloadJob = null
|
||||||
@@ -174,6 +183,7 @@ class DownloadManager(
|
|||||||
updateDownloadProgressState(
|
updateDownloadProgressState(
|
||||||
DownloadState.Error(sourceUnavailableMessage), 0f
|
DownloadState.Error(sourceUnavailableMessage), 0f
|
||||||
)
|
)
|
||||||
|
expireErrorStateToIdle()
|
||||||
return@withLock
|
return@withLock
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +240,7 @@ class DownloadManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
expireErrorStateToIdle()
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
downloadJob = null
|
downloadJob = null
|
||||||
|
|||||||
@@ -64,7 +64,11 @@ fun MainRoute(
|
|||||||
dictionary.isActive && dictionary.articleCount > 0
|
dictionary.isActive && dictionary.articleCount > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsState.downloadState is DownloadState.Idle &&
|
val downloadSettled = settingsState.downloadState.let { state ->
|
||||||
|
state is DownloadState.Idle || state is DownloadState.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadSettled &&
|
||||||
!settingsState.indexingProgress.isIndexing &&
|
!settingsState.indexingProgress.isIndexing &&
|
||||||
settingsState.importState !is ImportState.Importing &&
|
settingsState.importState !is ImportState.Importing &&
|
||||||
settingsState.importState !is ImportState.Extracting &&
|
settingsState.importState !is ImportState.Extracting &&
|
||||||
|
|||||||
Reference in new issue
Block a user