Skip to content

Commit

Permalink
Fix: Card browser contents not shown just after language change
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddheshjondhale committed Jan 15, 2025
1 parent 1f068d0 commit db00b47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ open class CardBrowser :
adapter.addAll(viewModel.column2Candidates.map { it.getLabel(cardsOrNotes) })
}
}
viewModel.flowOfInitCompleted.launchCollectionInLifecycleScope(::initCompletedChanged)
viewModel.flowOfIsTruncated.launchCollectionInLifecycleScope(::onIsTruncatedChanged)
viewModel.flowOfSearchQueryExpanded.launchCollectionInLifecycleScope(::onSearchQueryExpanded)
viewModel.flowOfSelectedRows.launchCollectionInLifecycleScope(::onSelectedRowsChanged)
Expand All @@ -582,7 +583,6 @@ open class CardBrowser :
viewModel.flowOfIsInMultiSelectMode.launchCollectionInLifecycleScope(::isInMultiSelectModeChanged)
viewModel.flowOfCardsUpdated.launchCollectionInLifecycleScope(::cardsUpdatedChanged)
viewModel.flowOfSearchState.launchCollectionInLifecycleScope(::searchStateChanged)
viewModel.flowOfInitCompleted.launchCollectionInLifecycleScope(::initCompletedChanged)
viewModel.flowOfCardsOrNotes.launchCollectionInLifecycleScope(::cardsOrNotesChanged)
}

Expand Down Expand Up @@ -891,6 +891,12 @@ open class CardBrowser :

override fun onResume() {
super.onResume()
lifecycleScope.launch {
// Reinitialize active browser columns when returning to this screen.
// Ensures the card browser displays the correct columns and data after a language change or configuration update.
val cardsOrNotes = viewModel.cardsOrNotes
viewModel.setupColumns(cardsOrNotes)
}
selectNavigationItem(R.id.nav_browser)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class CardBrowserViewModel(
}
}

private suspend fun setupColumns(cardsOrNotes: CardsOrNotes) {
suspend fun setupColumns(cardsOrNotes: CardsOrNotes) {
Timber.d("loading columns columns for %s mode", cardsOrNotes)
val columns = BrowserColumnCollection.load(sharedPrefs(), cardsOrNotes)
flowOfColumn1.update { columns.columns[0] }
Expand Down

0 comments on commit db00b47

Please sign in to comment.