diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/common/DrawerViewModel.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/common/DrawerViewModel.kt index f8301362dff..d942a3add09 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/common/DrawerViewModel.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/common/DrawerViewModel.kt @@ -41,6 +41,8 @@ import com.owncloud.android.providers.ContextProvider import com.owncloud.android.providers.CoroutinesDispatcherProvider import com.owncloud.android.usecases.accounts.RemoveAccountUseCase import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext import timber.log.Timber class DrawerViewModel( @@ -107,4 +109,12 @@ class DrawerViewModel( } } } + + fun checkUserLight(accountName: String): Boolean = runBlocking(CoroutinesDispatcherProvider().io) { + val quota = withContext(CoroutinesDispatcherProvider().io) { + getStoredQuotaUseCase(GetStoredQuotaUseCase.Params(accountName)) + } + quota.getDataOrNull()?.available == -4L + } + } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt index d4c8e5ca8a9..797399ff93d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt @@ -73,7 +73,6 @@ import com.owncloud.android.domain.files.model.FileListOption import com.owncloud.android.domain.files.model.OCFile import com.owncloud.android.domain.files.model.OCFile.Companion.ROOT_PARENT_ID import com.owncloud.android.domain.spaces.model.OCSpace -import com.owncloud.android.domain.user.model.UserQuota import com.owncloud.android.domain.utils.Event import com.owncloud.android.extensions.checkPasscodeEnforced import com.owncloud.android.extensions.collectLatestLifecycleFlow @@ -324,10 +323,9 @@ class FileDisplayActivity : FileActivity(), capabilitiesViewModel.capabilities.observe(this, Event.EventObserver { onCapabilitiesOperationFinish(it) }) + isLightUser = drawerViewModel.checkUserLight(account.name) + navigateTo(fileListOption, initialState = true) - drawerViewModel.userQuota.observe(this, Event.EventObserver { - onUserQuotaOperationFinish(it) - }) } startListeningToOperations() @@ -1522,15 +1520,6 @@ class FileDisplayActivity : FileActivity(), } } - private fun onUserQuotaOperationFinish(uiResult: UIResult) { - if (uiResult is UIResult.Success) { - if (uiResult.data?.available == -4L) { - isLightUser = true - } - } - navigateTo(fileListOption, initialState = true) - } - override fun onSavedCertificate() { startSyncFolderOperation(currentDir, false) }