Skip to content

Commit dbcde53

Browse files
committed
fix(deck-options): display optimize process in UI
`latestProgress` should not be a blocking call
1 parent 1d338b3 commit dbcde53

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/pages/PostRequestHandler.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.annotation.VisibleForTesting
2222
import androidx.fragment.app.FragmentActivity
2323
import androidx.lifecycle.lifecycleScope
2424
import anki.collection.OpChanges
25+
import com.ichi2.anki.CollectionManager
2526
import com.ichi2.anki.CollectionManager.withCol
2627
import com.ichi2.anki.NoteEditor
2728
import com.ichi2.anki.importAnkiPackageUndoable
@@ -36,6 +37,7 @@ import com.ichi2.libanki.getDeckNamesRaw
3637
import com.ichi2.libanki.getFieldNamesRaw
3738
import com.ichi2.libanki.getImportAnkiPackagePresetsRaw
3839
import com.ichi2.libanki.getNotetypeNamesRaw
40+
import com.ichi2.libanki.sched.computeFsrsParamsRaw
3941
import com.ichi2.libanki.sched.computeOptimalRetentionRaw
4042
import com.ichi2.libanki.sched.evaluateParamsRaw
4143
import com.ichi2.libanki.sched.simulateFsrsReviewRaw
@@ -82,7 +84,6 @@ val collectionMethods =
8284
"getImageForOcclusion" to { bytes -> getImageForOcclusionRaw(bytes) },
8385
"getImageOcclusionNote" to { bytes -> getImageOcclusionNoteRaw(bytes) },
8486
"setWantsAbort" to { bytes -> setWantsAbortRaw(bytes) },
85-
"latestProgress" to { bytes -> latestProgressRaw(bytes) },
8687
"getSchedulingStatesWithContext" to { bytes -> getSchedulingStatesWithContextRaw(bytes) },
8788
"setSchedulingStates" to { bytes -> setSchedulingStatesRaw(bytes) },
8889
"getChangeNotetypeInfo" to { bytes -> getChangeNotetypeInfoRaw(bytes) },
@@ -110,6 +111,7 @@ val uiMethods =
110111
hashMapOf<String, UIBackendInterface>(
111112
"searchInBrowser" to { bytes -> lifecycleScope.async { searchInBrowser(bytes) } },
112113
"updateDeckConfigs" to { bytes -> lifecycleScope.async { updateDeckConfigsRaw(bytes) } },
114+
"latestProgress" to { bytes -> lifecycleScope.async { CollectionManager.getBackend().latestProgressRaw(bytes) } },
113115
"importCsv" to { bytes -> lifecycleScope.async { importCsvRaw(bytes) } },
114116
"importAnkiPackage" to { bytes -> lifecycleScope.async { importAnkiPackageUndoable(bytes) } },
115117
"addImageOcclusionNote" to { bytes ->
@@ -122,7 +124,7 @@ val uiMethods =
122124
withCol { updateImageOcclusionNoteRaw(bytes) }
123125
}
124126
},
125-
"computeFsrsParams" to { bytes -> lifecycleScope.async { computeFsrsParams(bytes) } },
127+
"computeFsrsParams" to { bytes -> lifecycleScope.async { withCol { computeFsrsParamsRaw(bytes) } } },
126128
"deckOptionsReady" to { bytes -> lifecycleScope.async { deckOptionsReady(bytes) } },
127129
"deckOptionsRequireClose" to { bytes -> lifecycleScope.async { deckOptionsRequireClose(bytes) } },
128130
)

0 commit comments

Comments
 (0)