Skip to content

Commit

Permalink
Merge pull request #1834 from Infomaniak/attachments-animations
Browse files Browse the repository at this point in the history
Put back missing animations when removing Attachments
  • Loading branch information
KevinBoulongne committed May 1, 2024
2 parents b6a6d35 + 47a717b commit 627db89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ class NewMessageFragment : Fragment() {
saveDraft()
}

val shouldTransition = attachmentAdapter.itemCount != 0 && attachments.isEmpty()
attachmentAdapter.submitList(attachments)
if (shouldTransition) TransitionManager.beginDelayedTransition(binding.root)
// When removing an Attachment, both counts will be the same, because the Adapter is already notified.
// We don't want to notify it again, because it will cancel the nice animation.
if (attachments.count() != attachmentAdapter.itemCount) attachmentAdapter.submitList(attachments)

if (attachments.isEmpty()) TransitionManager.beginDelayedTransition(binding.root)
binding.attachmentsRecyclerView.isVisible = attachments.isNotEmpty()

updateIsSendingAllowed(attachments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ class NewMessageViewModel @Inject constructor(
val attachments = attachmentsLiveData.valueOrEmpty().toMutableList()
val attachment = attachments[position]
attachment.getUploadLocalFile()?.delete()
LocalStorageUtils.deleteAttachmentUploadDir(appContext, draftLocalUuid()!!, attachment.localUuid)
LocalStorageUtils.deleteAttachmentUploadDir(appContext, draftLocalUuid!!, attachment.localUuid)
attachments.removeAt(position)
attachmentsLiveData.value = attachments
}.onFailure { exception ->
Expand Down

0 comments on commit 627db89

Please sign in to comment.