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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import com.infomaniak.drive.ui.MainViewModel.FileResult
import com.infomaniak.drive.ui.fileList.DownloadProgressDialog.DownloadAction
import com.infomaniak.drive.ui.fileList.fileDetails.CategoriesUsageMode
import com.infomaniak.drive.ui.fileList.fileDetails.SelectCategoriesFragment
import com.infomaniak.drive.ui.menu.GalleryFragment.Companion.DELETE_FILE_KEY
import com.infomaniak.drive.utils.*
import com.infomaniak.drive.utils.Utils.openWith
import com.infomaniak.drive.views.FileInfoActionsView
Expand Down Expand Up @@ -438,6 +439,7 @@ class PreviewSliderFragment : Fragment(), FileInfoActionsView.OnItemClickListene
removeFileInSlider()
showSnackbar(getString(R.string.snackbarMoveTrashConfirmation, currentFile.name))
mainViewModel.deleteFileFromHome.value = true
setBackNavigationResult(DELETE_FILE_KEY, currentFile.id, withPopBackStack = false)
Copy link
Contributor

@KevinBoulongne KevinBoulongne Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use a SingleLiveEvent instead of tweaking an existing system that is not designed for this use case ?

} else {
showSnackbar(R.string.errorDelete)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.infomaniak.drive.utils.Utils
import com.infomaniak.drive.utils.getAdjustedColumnNumber
import com.infomaniak.drive.views.NoItemsLayoutView
import com.infomaniak.lib.core.utils.Utils.createRefreshTimer
import com.infomaniak.lib.core.utils.getBackNavigationResult
import com.infomaniak.lib.core.utils.setPagination
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -84,6 +85,10 @@ class GalleryFragment : MultiSelectFragment(MATOMO_CATEGORY), NoItemsLayoutView.
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

getBackNavigationResult<Int>(DELETE_FILE_KEY) { fileId ->
galleryAdapter.deleteByFileId(fileId)
}

setupPagination()

val isCurrentlyInGallery = menuGalleryBinding != null
Expand Down Expand Up @@ -331,5 +336,7 @@ class GalleryFragment : MultiSelectFragment(MATOMO_CATEGORY), NoItemsLayoutView.
const val TAG = "GalleryFragment"
const val MATOMO_CATEGORY = "picturesFileAction"
private const val NUMBER_ITEMS_LOADER = 13

const val DELETE_FILE_KEY = "sort_type_option"
}
}
Loading