Skip to content

Commit

Permalink
fix: created a new method in DrawerViewModel to avoid navigation wh…
Browse files Browse the repository at this point in the history
…en the quota is refreshed
  • Loading branch information
joragua committed Nov 29, 2024
1 parent 73336c8 commit dcfb6b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1522,15 +1520,6 @@ class FileDisplayActivity : FileActivity(),
}
}

private fun onUserQuotaOperationFinish(uiResult: UIResult<UserQuota?>) {
if (uiResult is UIResult.Success) {
if (uiResult.data?.available == -4L) {
isLightUser = true
}
}
navigateTo(fileListOption, initialState = true)
}

override fun onSavedCertificate() {
startSyncFolderOperation(currentDir, false)
}
Expand Down

0 comments on commit dcfb6b8

Please sign in to comment.