Skip to content

Conversation

@PandaGuerrier
Copy link
Member

This pull request refactors and simplifies the handling of media assets and file attachments throughout the codebase. The main focus is on introducing a new Asset class to unify the representation of media files, replacing older classes and patterns, and updating related components and utilities to use this new abstraction.

Key changes include:

Media Asset Abstraction and Refactoring:

  • Introduced a new Asset class in asset.dart to represent media assets, supporting construction from files and providing a consistent toJson interface. ([lib/src/api/common/components/asset.dartR1-R53](https://github.com/mineral-dart/core/pull/308/files#diff-3fbbfd1a71c21b0da772f58f73fc1b0182a879136d2daa58247dad63b495895cR1-R53))
  • Refactored MessageGallery and MessageThumbnail to use the new Asset class instead of custom GalleryItem and MessageMedia classes, and removed those now-obsolete classes. ([[1]](https://github.com/mineral-dart/core/pull/308/files#diff-0fdf1ae2b9b8e602b0b3f0891e59f4816b3d55d643beb10bf3fddd73f6929b97L1-R8), [[2]](https://github.com/mineral-dart/core/pull/308/files#diff-0fdf1ae2b9b8e602b0b3f0891e59f4816b3d55d643beb10bf3fddd73f6929b97L19-L81), [[3]](https://github.com/mineral-dart/core/pull/308/files#diff-b525cb54063745dbe2f6788352f43c9739fd84c1d8ac0b2373691ca4da3f42ddL1-L15), [[4]](https://github.com/mineral-dart/core/pull/308/files#diff-8f28f0b16ea988f78630dfe810fd3531d01a5566c3452dd52f22b4ae9fb9586fR5-R13))

File Attachment Handling:

  • Renamed and refactored the file attachment class from Attachment to MessageFile, simplifying its API and removing caching logic. Updated the file method in MessageBuilder to use MessageFile. ([[1]](https://github.com/mineral-dart/core/pull/308/files#diff-51664875c1f9dfced04f6ef0abd776771dedd208d062aaeaafa2198925f52cdcL7-R27), [[2]](https://github.com/mineral-dart/core/pull/308/files#diff-c826a76b7e732d8d76753211299eb15d5083b70a77bc3f8b2e1395d9ef2b7977L79-R79))
  • Updated exports in api.dart to reflect the new and removed classes, ensuring the public API is consistent with these changes. ([lib/api.dartR30-L37](https://github.com/mineral-dart/core/pull/308/files#diff-af9ff7cdb71adcd379123b2b2de8b383941c39b54a0cb1a07dc784ccb0aae6c1R30-L37))

Attachment Utilities Update:

  • Refactored the attachment utility in attachment.dart to handle the new Asset structure, updating how multipart files are prepared and attached for both files and gallery/media assets. ([[1]](https://github.com/mineral-dart/core/pull/308/files#diff-1737ee8ca6e3b58944c539226c2955ec393db6d878b4388d752a58542d4ffea2L4-R4), [[2]](https://github.com/mineral-dart/core/pull/308/files#diff-1737ee8ca6e3b58944c539226c2955ec393db6d878b4388d752a58542d4ffea2L17-R73))

Overall, these changes modernize and streamline the way media and files are handled in messages, making the codebase easier to maintain and extend.

@PandaGuerrier PandaGuerrier linked an issue Nov 7, 2025 that may be closed by this pull request
@PandaGuerrier PandaGuerrier self-assigned this Nov 7, 2025
@PandaGuerrier PandaGuerrier merged commit ef22e82 into main Nov 10, 2025
@PandaGuerrier PandaGuerrier deleted the 306-rework-attachments-in-interaction-for-better-dev branch November 10, 2025 21:43
@DCodeProg
Copy link
Contributor

Nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework attachments in interaction for better dev

4 participants