Fix listing when credential changed in background due to auth problem

E.g. the token is expired and was refreshed
This commit is contained in:
Julian Raufelder 2022-01-26 16:02:29 +01:00
parent e11759b23f
commit 11f5a61789
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D
2 changed files with 17 additions and 2 deletions

View File

@ -8,7 +8,7 @@ public class CryptoCloud implements Cloud {
private final Vault vault; private final Vault vault;
CryptoCloud(Vault vault) { public CryptoCloud(Vault vault) {
this.vault = vault; this.vault = vault;
} }

View File

@ -6,9 +6,12 @@ import android.content.Intent
import android.net.Uri import android.net.Uri
import android.provider.DocumentsContract import android.provider.DocumentsContract
import android.widget.Toast import android.widget.Toast
import org.cryptomator.data.cloud.crypto.CryptoCloud
import org.cryptomator.data.cloud.crypto.CryptoFolder
import org.cryptomator.domain.CloudFile import org.cryptomator.domain.CloudFile
import org.cryptomator.domain.CloudFolder import org.cryptomator.domain.CloudFolder
import org.cryptomator.domain.CloudNode import org.cryptomator.domain.CloudNode
import org.cryptomator.domain.Vault
import org.cryptomator.domain.di.PerView import org.cryptomator.domain.di.PerView
import org.cryptomator.domain.exception.CloudNodeAlreadyExistsException import org.cryptomator.domain.exception.CloudNodeAlreadyExistsException
import org.cryptomator.domain.exception.EmptyDirFileException import org.cryptomator.domain.exception.EmptyDirFileException
@ -49,6 +52,7 @@ import org.cryptomator.presentation.intent.IntentBuilder
import org.cryptomator.presentation.intent.Intents import org.cryptomator.presentation.intent.Intents
import org.cryptomator.presentation.model.CloudFileModel import org.cryptomator.presentation.model.CloudFileModel
import org.cryptomator.presentation.model.CloudFolderModel import org.cryptomator.presentation.model.CloudFolderModel
import org.cryptomator.presentation.model.CloudModel
import org.cryptomator.presentation.model.CloudNodeModel import org.cryptomator.presentation.model.CloudNodeModel
import org.cryptomator.presentation.model.ImagePreviewFilesStore import org.cryptomator.presentation.model.ImagePreviewFilesStore
import org.cryptomator.presentation.model.ProgressModel import org.cryptomator.presentation.model.ProgressModel
@ -223,7 +227,18 @@ class BrowseFilesPresenter @Inject constructor( //
@Callback @Callback
fun getCloudListAfterAuthentication(result: ActivityResult, cloudFolderModel: CloudFolderModel) { fun getCloudListAfterAuthentication(result: ActivityResult, cloudFolderModel: CloudFolderModel) {
getCloudList(cloudFolderModel) val cloudModel = result.getSingleResult(CloudModel::class.java)
val cloudNode = cloudFolderModel.toCloudNode()
val updatedCloud = if (cloudNode is CryptoFolder) {
CryptoCloud(Vault.aCopyOf(cloudFolderModel.vault()?.toVault()).withCloud(cloudModel.toCloud()).build())
} else {
cloudModel.toCloud()
}
cloudNode.withCloud(updatedCloud)?.let {
getCloudList(cloudFolderModelMapper.toModel(it))
} ?: throw FatalBackendException("cloudFolderModel with updated Cloud shouldn't be null")
} }
fun onCreateFolderPressed(cloudFolder: CloudFolderModel, folderName: String?) { fun onCreateFolderPressed(cloudFolder: CloudFolderModel, folderName: String?) {