Fix "Cannot connect to crypto provider"

Initialize `openPgpCallback` before `onSwitchAccount()` is called from the class initializer.
This commit is contained in:
Georg Sieber 2023-05-22 10:42:19 +02:00 committed by GitHub
parent 726027f961
commit 7edbe542bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,6 +90,24 @@ class RecipientPresenter(
private val allRecipients: List<Recipient>
get() = with(recipientMvpView) { toRecipients + ccRecipients + bccRecipients }
private val openPgpCallback = object : OpenPgpApiManagerCallback {
override fun onOpenPgpProviderStatusChanged() {
if (openPgpApiManager.openPgpProviderState == OpenPgpProviderState.UI_REQUIRED) {
recipientMvpView.showErrorOpenPgpUserInteractionRequired()
}
asyncUpdateCryptoStatus()
}
override fun onOpenPgpProviderError(error: OpenPgpProviderError) {
when (error) {
OpenPgpProviderError.ConnectionLost -> openPgpApiManager.refreshConnection()
OpenPgpProviderError.VersionIncompatible -> recipientMvpView.showErrorOpenPgpIncompatible()
OpenPgpProviderError.ConnectionFailed -> recipientMvpView.showErrorOpenPgpConnection()
else -> recipientMvpView.showErrorOpenPgpConnection()
}
}
}
init {
recipientMvpView.setPresenter(this)
recipientMvpView.setLoaderManager(loaderManager)
@ -723,25 +741,6 @@ class RecipientPresenter(
}
}
private val openPgpCallback = object : OpenPgpApiManagerCallback {
override fun onOpenPgpProviderStatusChanged() {
if (openPgpApiManager.openPgpProviderState == OpenPgpProviderState.UI_REQUIRED) {
recipientMvpView.showErrorOpenPgpUserInteractionRequired()
}
asyncUpdateCryptoStatus()
}
override fun onOpenPgpProviderError(error: OpenPgpProviderError) {
when (error) {
OpenPgpProviderError.ConnectionLost -> openPgpApiManager.refreshConnection()
OpenPgpProviderError.VersionIncompatible -> recipientMvpView.showErrorOpenPgpIncompatible()
OpenPgpProviderError.ConnectionFailed -> recipientMvpView.showErrorOpenPgpConnection()
else -> recipientMvpView.showErrorOpenPgpConnection()
}
}
}
private fun Array<String>.toAddressArray(): Array<Address> {
return flatMap { addressString ->
Address.parseUnencoded(addressString).toList()