0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00

Fix: Ensure Media Sync Aborted Message Displays Correctly After Canceling Media Sync

This commit is contained in:
Sumit Singh 2024-09-01 15:39:36 +05:30 committed by David Allison
parent 941be0ce2a
commit 9c9018b049

View File

@ -358,6 +358,7 @@ suspend fun monitorMediaSync(
) {
val backend = CollectionManager.getBackend()
val scope = CoroutineScope(Dispatchers.IO)
var isAborted = false
val dialog = withContext(Dispatchers.Main) {
AlertDialog.Builder(deckPicker)
@ -367,6 +368,7 @@ suspend fun monitorMediaSync(
scope.cancel()
}
.setNegativeButton(TR.syncAbortButton()) { _, _ ->
isAborted = true
cancelMediaSync(backend)
}
.show()
@ -386,7 +388,7 @@ suspend fun monitorMediaSync(
dialog.setMessage(text)
delay(100)
}
showMessage(TR.syncMediaComplete())
showMessage(if (isAborted) TR.syncMediaAborted() else TR.syncMediaComplete())
} catch (_: BackendInterruptedException) {
showMessage(TR.syncMediaAborted())
} catch (_: CancellationException) {