From 4bd2cd1e09d4811119875940148840577efe32ec Mon Sep 17 00:00:00 2001 From: lukstbit <52494258+lukstbit@users.noreply.github.com> Date: Thu, 2 May 2024 17:00:33 +0300 Subject: [PATCH] Fix refresh of DeckPicker UI after a new collection import The fix introduces a call to withCol {} to make sure the collection is open and available before any of the code that updates the UI in DeckPicker runs. --- AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt index a1494eb57f9b..d17d8a25b570 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt @@ -2635,9 +2635,14 @@ open class DeckPicker : } override fun onImportColpkg(colpkgPath: String?) { - invalidateOptionsMenu() - updateDeckList() - importColpkgListener?.onImportColpkg(colpkgPath) + launchCatchingTask { + // as the current collection is closed before importing a new collection, make sure the + // new collection is open before the code to update the DeckPicker ui runs + withCol { } + invalidateOptionsMenu() + updateDeckList() + importColpkgListener?.onImportColpkg(colpkgPath) + } } override fun onMediaSyncCompleted(data: SyncCompletion) {