Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Card browser list contents not shown just after language change #17823

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading