Skip to content

Commit

Permalink
Work around a lifecycle issue
Browse files Browse the repository at this point in the history
This (potentially) works around a lifecycle issue where opening the
account picker from the catalog might fail due to strange things
happening with the fragment backstack.

Affects: https://ebce-lyrasis.atlassian.net/browse/PP-657
Affects: https://console.firebase.google.com/u/0/project/the-palace-project/crashlytics/app/android:org.thepalaceproject.palace/issues/b276eed10069e4281933ad2821a86091
  • Loading branch information
io7m committed Nov 1, 2023
1 parent f14b01f commit 7a3f798
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,18 +606,22 @@ class CatalogFeedFragment : Fragment(R.layout.feed), AgeGateDialog.BirthYearSele
}

private fun openAccountPickerDialog() {
return when (val ownership = this.parameters.ownership) {
is OwnedByAccount -> {
val dialog =
AccountPickerDialogFragment.create(
currentId = ownership.accountId,
showAddAccount = this.configurationService.allowAccountsAccess
)
dialog.show(parentFragmentManager, dialog.tag)
}
CollectedFromAccounts -> {
throw IllegalStateException("Can't switch account from collected feed!")
try {
return when (val ownership = this.parameters.ownership) {
is OwnedByAccount -> {
val dialog =
AccountPickerDialogFragment.create(
currentId = ownership.accountId,
showAddAccount = this.configurationService.allowAccountsAccess
)
dialog.show(requireActivity().supportFragmentManager, dialog.tag)
}
CollectedFromAccounts -> {
throw IllegalStateException("Can't switch account from collected feed!")
}
}
} catch (e: Exception) {
this.logger.error("Failed to open account picker dialog: ", e)
}
}

Expand Down

0 comments on commit 7a3f798

Please sign in to comment.