Skip to content

Commit

Permalink
chore(card-browser): logs
Browse files Browse the repository at this point in the history
  • Loading branch information
david-allison authored and lukstbit committed Jun 4, 2024
1 parent b5acdca commit 812fd2c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,14 @@ class CardBrowserViewModel(

fun selectAll() {
if (_selectedRows.addAll(cards.wrapped)) {
Timber.d("selecting all: %d item(s)", cards.wrapped.size)
refreshSelectedRowsFlow()
}
}

fun selectNone() {
if (_selectedRows.isEmpty()) return
Timber.d("selecting none")
_selectedRows.clear()
refreshSelectedRowsFlow()
}
Expand Down Expand Up @@ -482,6 +484,7 @@ class CardBrowserViewModel(
sched.suspendCards(cardIds).changes
}
}
Timber.d("finished 'toggleSuspendCards'")
}

/**
Expand Down
8 changes: 6 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ open class Scheduler(val col: Collection) {
* @param ids Id of cards to suspend
*/
open fun suspendCards(ids: Iterable<CardId>): OpChangesWithCount {
val cids = ids.toList()
Timber.i("suspending %d card(s)", cids.size)
return col.backend.buryOrSuspendCards(
cardIds = ids.toList(),
cardIds = cids,
noteIds = listOf(),
mode = BuryOrSuspendCardsRequest.Mode.SUSPEND
)
Expand All @@ -251,8 +253,10 @@ open class Scheduler(val col: Collection) {
* @param ids Id of cards to unsuspend
*/
open fun unsuspendCards(ids: Iterable<CardId>): OpChanges {
val cids = ids.toList()
Timber.i("unsuspending %d card(s)", cids.size)
return col.backend.restoreBuriedAndSuspendedCards(
cids = ids.toList()
cids = cids
)
}

Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ open class JvmTest : TestClass {
Dispatchers.resetMain()
runBlocking { CollectionManager.discardBackend() }
Timber.uprootAll()
println("""-- executing test "${testName.methodName}"""")
println("""-- completed test "${testName.methodName}"""")
}

fun <T> assumeThat(actual: T, matcher: Matcher<T>?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ suspend fun ensureOpsExecuted(count: Int, block: suspend () -> Unit) {
Timber.d("ChangeManager op detected")
changes++
}
Timber.v("Listening for ChangeManager ops")
block()
// we should be fine to not cleanup here, as the subscriber goes out of scope
assertThat("ChangeManager: expected $count calls", changes, equalTo(count))
Expand Down

0 comments on commit 812fd2c

Please sign in to comment.