Skip to content

Commit

Permalink
Update toolbar only when the folder displayed changes, not any change…
Browse files Browse the repository at this point in the history
… in search filters or files content
  • Loading branch information
abelgardep committed Feb 24, 2023
1 parent 3a054b0 commit 5ecf394
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
)
Expand All @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 5ecf394

Please sign in to comment.