@@ -22,6 +22,7 @@ import androidx.annotation.VisibleForTesting
2222import androidx.fragment.app.FragmentActivity
2323import androidx.lifecycle.lifecycleScope
2424import anki.collection.OpChanges
25+ import com.ichi2.anki.CollectionManager
2526import com.ichi2.anki.CollectionManager.withCol
2627import com.ichi2.anki.NoteEditor
2728import com.ichi2.anki.importAnkiPackageUndoable
@@ -36,6 +37,7 @@ import com.ichi2.libanki.getDeckNamesRaw
3637import com.ichi2.libanki.getFieldNamesRaw
3738import com.ichi2.libanki.getImportAnkiPackagePresetsRaw
3839import com.ichi2.libanki.getNotetypeNamesRaw
40+ import com.ichi2.libanki.sched.computeFsrsParamsRaw
3941import com.ichi2.libanki.sched.computeOptimalRetentionRaw
4042import com.ichi2.libanki.sched.evaluateParamsRaw
4143import com.ichi2.libanki.sched.simulateFsrsReviewRaw
@@ -45,8 +47,10 @@ import com.ichi2.libanki.stats.graphsRaw
4547import com.ichi2.libanki.stats.setGraphPreferencesRaw
4648import com.ichi2.libanki.undoableOp
4749import kotlinx.coroutines.Deferred
50+ import kotlinx.coroutines.Dispatchers
4851import kotlinx.coroutines.async
4952import kotlinx.coroutines.delay
53+ import kotlinx.coroutines.withContext
5054import timber.log.Timber
5155
5256interface PostRequestHandler {
@@ -77,12 +81,12 @@ val collectionMethods =
7781 " cardStats" to { bytes -> cardStatsRaw(bytes) },
7882 " getDeckConfigsForUpdate" to { bytes -> getDeckConfigsForUpdateRaw(bytes) },
7983 " computeOptimalRetention" to { bytes -> computeOptimalRetentionRaw(bytes) },
84+ " computeFsrsParams" to { bytes -> computeFsrsParamsRaw(bytes) },
8085 " evaluateParams" to { bytes -> evaluateParamsRaw(bytes) },
8186 " simulateFsrsReview" to { bytes -> simulateFsrsReviewRaw(bytes) },
8287 " getImageForOcclusion" to { bytes -> getImageForOcclusionRaw(bytes) },
8388 " getImageOcclusionNote" to { bytes -> getImageOcclusionNoteRaw(bytes) },
8489 " setWantsAbort" to { bytes -> setWantsAbortRaw(bytes) },
85- " latestProgress" to { bytes -> latestProgressRaw(bytes) },
8690 " getSchedulingStatesWithContext" to { bytes -> getSchedulingStatesWithContextRaw(bytes) },
8791 " setSchedulingStates" to { bytes -> setSchedulingStatesRaw(bytes) },
8892 " getChangeNotetypeInfo" to { bytes -> getChangeNotetypeInfoRaw(bytes) },
@@ -110,6 +114,13 @@ val uiMethods =
110114 hashMapOf<String , UIBackendInterface >(
111115 " searchInBrowser" to { bytes -> lifecycleScope.async { searchInBrowser(bytes) } },
112116 " updateDeckConfigs" to { bytes -> lifecycleScope.async { updateDeckConfigsRaw(bytes) } },
117+ " latestProgress" to { bytes ->
118+ lifecycleScope.async {
119+ withContext(Dispatchers .IO ) {
120+ CollectionManager .getBackend().latestProgressRaw(bytes)
121+ }
122+ }
123+ },
113124 " importCsv" to { bytes -> lifecycleScope.async { importCsvRaw(bytes) } },
114125 " importAnkiPackage" to { bytes -> lifecycleScope.async { importAnkiPackageUndoable(bytes) } },
115126 " addImageOcclusionNote" to { bytes ->
@@ -122,7 +133,6 @@ val uiMethods =
122133 withCol { updateImageOcclusionNoteRaw(bytes) }
123134 }
124135 },
125- " computeFsrsParams" to { bytes -> lifecycleScope.async { computeFsrsParams(bytes) } },
126136 " deckOptionsReady" to { bytes -> lifecycleScope.async { deckOptionsReady(bytes) } },
127137 " deckOptionsRequireClose" to { bytes -> lifecycleScope.async { deckOptionsRequireClose(bytes) } },
128138 )
0 commit comments