Skip to content

Conversation

nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Apr 15, 2025

🔗 Issue Links

https://linear.app/stream/issue/IOS-648/[swiftui]-cant-edit-attachments-for-messages

🎯 Goal

Add support for editing message attachments. Plus, fixes minor issues related to editing messages.

📝 Summary

  • Adds support for editing message attachments
  • Fixes having message edit action on Giphy messages
  • Fixes scrolling to the bottom when editing a message
  • Fixes being able to long press an unsent Giphy message
  • Fixes being able to swipe to reply an unsent Giphy message
  • Deprecated ComposerConfig.attachmentPayloadConverter in favour of MessageComposerViewModel.inputAttachmentsAsPayloads()

🛠 Implementation

I had to be a bit creative in order to be able to convert the existing attachments of a message to our composer "Added" assets.

The main issue is that when editing a message, we used ComposerConfig.defaultAttachmentPayloadConverter to retain the existing attachments of the message. But now, this does not work well because the attachments do not come from a ChatMessage anymore but from our "Added" assets, just like we do with our Draft messages. For this reason, I had to deprecate the ComposerConfig.defaultAttachmentPayloadConverter. However, if a customer uses it, we fall back on it and ignore the new implementation.

I reused most of the logic of the Drafts implementation, but the difference is that the draft attachments are all local attachments, while the existing attachments of a message are already on the server, so I had to make some adjustments when converting the attachments to Added Assets.

Another challenge was that we expose the addedFileUrls as simply URLs. So, I had to create an additional property to store additional information about the removed file URLs.

🧪 Manual Testing Notes

Add support for editing message attachments

  1. Long tap on a message with attachments
  2. Tap on Edit message
  3. Add a new attachment and remove existing attachments
  4. Publish the message
  5. The message should be updated with the new attachments
    Note: Test with multiple types of attachments (image, video, file, voice recording etc)

Fix scrolling to the bottom when editing a message

  1. Scroll to a message on an older page
  2. Edit a message
  3. Publish the message
  4. It should not scroll to the bottom

Fix having message edit action on Giphy messages

  1. Long tap in a Giphy message created by the current user
  2. Should not contain edit action

Fix being able to long press an unsent Giphy message

  1. Create a giphy
  2. Stay in the Actions View (Send, shuffle, cancel)
  3. Long tap the giphy in the ephemeral state should not show message actions

Fix being able to swipe to reply an unsent Giphy message

  1. Create a giphy
  2. Stay in the Actions View (Send, shuffle, cancel)
  3. Swiping the giphy in the ephemeral state should not trigger quote reply animation

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

@nuno-vieira nuno-vieira added 🐞 Bug ✅ Feature An issue or PR related to a feature labels Apr 15, 2025
@nuno-vieira nuno-vieira requested a review from a team as a code owner April 15, 2025 16:33
@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Apr 15, 2025

SDK Size

title develop branch diff status
StreamChatSwiftUI 8.21 MB 8.23 MB +18 KB 🟢

@nuno-vieira nuno-vieira changed the title Add/edit message attachments Add support for editing attachments Apr 15, 2025
Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

Works well and looks good, just left few minor comments

Copy link

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
79.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

@nuno-vieira nuno-vieira merged commit c1b0a30 into develop Apr 18, 2025
11 of 12 checks passed
@nuno-vieira nuno-vieira deleted the add/edit-message-attachments branch April 18, 2025 13:28
@nuno-vieira nuno-vieira restored the add/edit-message-attachments branch April 18, 2025 13:31
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 Bug ✅ Feature An issue or PR related to a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants