feat: Only show processing dialog after some time

Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
Myzel394 2024-03-23 14:01:53 +01:00
parent 7d83bca1fe
commit cfea5a9143
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185

View File

@ -33,6 +33,8 @@ import app.myzel394.alibi.ui.utils.rememberFileSaverDialog
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.util.Timer
import kotlin.concurrent.schedule
import kotlin.concurrent.thread
typealias RecorderModel = BaseRecorderModel<
@ -140,10 +142,13 @@ fun RecorderEventsHandler(
recorder: RecorderModel,
cleanupOldFiles: Boolean = false
): CompletableDeferred<Unit> {
isProcessing = true
val completer = CompletableDeferred<Unit>()
// If processing takes this short, don't show the processing dialog
val timer = Timer().schedule(250L) {
isProcessing = true
}
thread {
runBlocking {
try {
@ -231,6 +236,7 @@ fun RecorderEventsHandler(
if (recorder.isCurrentlyActivelyRecording) {
recorder.recorderService?.unlockFiles(cleanupOldFiles)
}
timer.cancel()
isProcessing = false
processingProgress = null
completer.complete(Unit)