From 5ecf394ecf70cd4335193b5f1ca9b191a8f31a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Fri, 24 Feb 2023 15:02:41 +0100 Subject: [PATCH] Update toolbar only when the folder displayed changes, not any change in search filters or files content --- .../files/filelist/MainFileListFragment.kt | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt index fb00a7a6a89..e221ae82a2c 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt @@ -83,6 +83,7 @@ import com.owncloud.android.ui.activity.FileActivity import com.owncloud.android.ui.activity.FileDisplayActivity import com.owncloud.android.ui.activity.FolderPickerActivity import com.owncloud.android.ui.dialog.ConfirmationDialogFragment +import kotlinx.coroutines.delay import org.koin.androidx.viewmodel.ext.android.sharedViewModel import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf @@ -212,17 +213,15 @@ class MainFileListFragment : Fragment(), private fun subscribeToViewModels() { // Observe the current folder displayed - collectLatestLifecycleFlow(mainFileListViewModel.currentFolderDisplayed) { - if (getCurrentSpace() == null) { - fileActions?.onCurrentFolderUpdated(it) - } + collectLatestLifecycleFlow(mainFileListViewModel.currentFolderDisplayed) { currentFolderDisplayed: OCFile -> + fileActions?.onCurrentFolderUpdated(currentFolderDisplayed, mainFileListViewModel.getSpace()) val fileListOption = mainFileListViewModel.fileListOption.value val refreshFolderNeeded = fileListOption.isAllFiles() || - (!fileListOption.isAllFiles() && it.remotePath != ROOT_PATH) + (!fileListOption.isAllFiles() && currentFolderDisplayed.remotePath != ROOT_PATH) if (refreshFolderNeeded) { fileOperationsViewModel.performOperation( FileOperation.RefreshFolderOperation( - folderToRefresh = it, + folderToRefresh = currentFolderDisplayed, shouldSyncContents = !isPickingAFolder(), // For picking a folder option, we just need a refresh ) ) @@ -236,16 +235,16 @@ class MainFileListFragment : Fragment(), fileListAdapter.updateFileList(filesToAdd = fileListUiState.folderContent, fileListOption = fileListUiState.fileListOption) showOrHideEmptyView(fileListUiState) - binding.spaceHeader.root.apply { - if (fileListUiState.space?.isProject == true && fileListUiState.folderToDisplay?.remotePath == ROOT_PATH) { - isVisible = true - animate().translationY(0f).duration = 100 - } else { - animate().translationY(-height.toFloat()).withEndAction { isVisible = false } + fileListUiState.space?.let { + binding.spaceHeader.root.apply { + if (fileListUiState.space.isProject && fileListUiState.folderToDisplay?.remotePath == ROOT_PATH) { + isVisible = true + animate().translationY(0f).duration = 100 + } else { + animate().translationY(-height.toFloat()).withEndAction { isVisible = false } + } } - } - fileListUiState.space?.let { val spaceSpecialImage = it.getSpaceSpecialImage() if (spaceSpecialImage != null) { binding.spaceHeader.spaceHeaderImage.tag = spaceSpecialImage.id @@ -262,7 +261,6 @@ class MainFileListFragment : Fragment(), } binding.spaceHeader.spaceHeaderName.text = it.name binding.spaceHeader.spaceHeaderSubtitle.text = it.description - fileActions?.onCurrentFolderUpdated(fileListUiState.folderToDisplay!!, it) } actionMode?.invalidate()