Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix files that persist in the gallery when deleted in the preview #1440

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/com/infomaniak/drive/ui/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class MainViewModel(
private var syncOfflineFilesJob = Job()
private var setCurrentFolderJob = Job()

val deleteFilesFromGallery = SingleLiveEvent<List<Int>>()

private fun getContext() = getApplication<MainApplication>()

fun setCurrentFolder(folder: File?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ class PreviewSliderFragment : BasePreviewSliderFragment(), FileInfoActionsView.O
removeFileInSlider()
showSnackbar(getString(R.string.snackbarMoveTrashConfirmation, currentFile.name))
mainViewModel.deleteFileFromHome.value = true
mainViewModel.deleteFilesFromGallery.postValue(
mainViewModel.deleteFilesFromGallery.value?.plus(currentFile.id) ?: listOf(currentFile.id)
)
} else {
showSnackbar(R.string.errorDelete)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ class GalleryFragment : MultiSelectFragment(MATOMO_CATEGORY), NoItemsLayoutView.
}

observeApiResultPagination()

mainViewModel.deleteFilesFromGallery.observe(viewLifecycleOwner) { filesId ->
filesId.forEach { fileId -> galleryAdapter.deleteByFileId(fileId) }
TommyDL-Infomaniak marked this conversation as resolved.
Show resolved Hide resolved
}
}

private fun observeApiResultPagination() {
Expand Down
Loading