-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix deleting from slideshow #15669
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
base: master
Are you sure you want to change the base?
Fix deleting from slideshow #15669
Conversation
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
The patch added in nextcloud#14782 prevented that the callback onRemoteOperationFinish() was ever called. Secondly, the manual update of adapter and pager is only needed if user is not present. When user is present, the initViewPager() takes care of everything. Signed-off-by: Philipp Hasper <vcs@hasper.info>
In that case, deleting the currently viewed file had the following issues: 1. When deleting the first image, the UI just stayed with it. 2. When deleting another image, the UI switched to the previous image, instead of the next one, which is inconsistent to the behavior when user is available 3. When switching to the next image, the title shown at the top did not correctly update Signed-off-by: Philipp Hasper <vcs@hasper.info>
94917e8
to
3143bb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Re-init the view pager, which will advance to the next image | ||
initViewPager(user.get()) | ||
} else if (result.isSuccess) { | ||
// If deletion was successful, update adapter and display next image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove comments and extract else if (result.isSuccess) {
logic to the separate function, e.g. updateViewPagerAfterDeletion()
thus it will be also clear without comments.
override fun getItemId(position: Int): Long { | ||
// The item ID function is needed to detect whether the deletion of the current item needs a UI update | ||
// Use the OCFile id, fallback to position if not available | ||
return imageFiles.getOrNull(position)?.fileId?.toLong() ?: position.toLong() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getItemId()
is part of androidx.viewpager2.adapter.FragmentStateAdapter
. No need to add an explanation here since the method is already documented in the official API.
Additionally, please remove unnecessary toLong()
cast for fileId
since fileId
is already Long.
Fixes #15636.
onRemoteOperationFinish()
was ever called.The changes were removed. I was not able to reproduce the end-to-end encryption issue, so this seems fine.
initViewPager()
takes care of everything.