-
Notifications
You must be signed in to change notification settings - Fork 213
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
Download and share attachments #3393
Conversation
Sources/StreamChat/Models/Attachments/ChatMessageAttachment.swift
Outdated
Show resolved
Hide resolved
Generated by 🚫 Danger |
19562ca
to
8af3297
Compare
SDK Size
|
8af3297
to
bae20e3
Compare
bae20e3
to
ee766d8
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.
Looks good 👍 Added few comments.
Sources/StreamChat/Models/Attachments/ChatMessageAttachment.swift
Outdated
Show resolved
Hide resolved
e6564af
to
2048233
Compare
…alid only when downloading has been finished
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.
The new methods look good 👍 Additionally, we need to update the changelog, show some examples in the docs and write some tests.
Sources/StreamChat/Controllers/CurrentUserController/CurrentUserController.swift
Show resolved
Hide resolved
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.
Its looking good overall but I believe there are still 2 points that we need to address:
1- Custom Attachments being downloadable
2- Making sure we don't break customers current UI
Sources/StreamChat/APIClient/AttachmentDownloader/AttachmentDownloader.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/APIClient/AttachmentDownloader/AttachmentDownloader.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/APIClient/AttachmentDownloader/AttachmentDownloader.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Models/Attachments/ChatMessageAttachment.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/APIClient/AttachmentDownloader/AttachmentDownloader.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatUI/ChatMessageList/Attachments/File/ChatFileAttachmentListView+ItemView.swift
Outdated
Show resolved
Hide resolved
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.
Almost there 👌 Just added a few more comments 👍
Sources/StreamChat/APIClient/AttachmentDownloader/AttachmentDownloader.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Models/Attachments/ChatMessageGiphyAttachment.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChat/Models/Attachments/ChatMessageVoiceRecordingAttachment.swift
Show resolved
Hide resolved
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.
LGTM! ✅
|
🔗 Issue Links
Resolves: PBE-4725
🎯 Goal
Show an action for downloading individual attachments and sharing them with the share sheet
📝 Summary
Chat.downloadAttachment(_:)
(async throws)Chat.deleteLocalAttachmentDownload(for:)
(async throws)ConnectedUser.deleteAllLocalAttachmentDownloads()
(async throws)MessageController.downloadAttachment(_:completion:)
MessageController.deleteLocalAttachmentDownload(for:completion:)
CurrentUserController.deleteAllLocalAttachmentDownloads()
Components.default.isDownloadFileAttachmentsEnabled
isDownloadFileAttachmentsEnabled
🛠 Implementation
Added a download icon to file attachments which triggers the local attachment download. Attachments are downloaded to "AttachmentDownloads" folder in user's documents directory. Relative path to the downloaded file is kept in the local DB. If the attachment has been downloaded, a share button appears which allows users to share the downloaded attachment.
🎨 Showcase
🧪 Manual Testing Notes
Note: Turn on configuration option:
isDownloadFileAttachmentsEnabled
Case 1
Result: download icon appears after uploading
Case 2
Result: Attachment file appears in the Notes app and Files app.
Case 3
Result: Attachment views update to show download icon instead of share icon and the file can be downloaded again.
Case 4
Result: Attachments show download icon because logout deletes local downloads
☑️ Contributor Checklist
🎁 Meme
Provide a funny gif or image that relates to your work on this pull request. (Optional)