Skip to content
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

Merged
merged 31 commits into from
Aug 30, 2024
Merged

Download and share attachments #3393

merged 31 commits into from
Aug 30, 2024

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Aug 22, 2024

🔗 Issue Links

Resolves: PBE-4725

🎯 Goal

Show an action for downloading individual attachments and sharing them with the share sheet

📝 Summary

  • Added public APIs (known attachment types can be downloaded)
    • Chat.downloadAttachment(_:) (async throws)
    • Chat.deleteLocalAttachmentDownload(for:) (async throws)
    • ConnectedUser.deleteAllLocalAttachmentDownloads()(async throws)
    • MessageController.downloadAttachment(_:completion:)
    • MessageController.deleteLocalAttachmentDownload(for:completion:)
    • CurrentUserController.deleteAllLocalAttachmentDownloads()
  • Added download and share buttons to the file attachment view
    • Feature toggle: Components.default.isDownloadFileAttachmentsEnabled
  • Documentation on the getstream.io
  • Demo app
    • Configuration option for isDownloadFileAttachmentsEnabled
    • Debug command: "Delete Downloaded Attachments"

🛠 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

img

🧪 Manual Testing Notes

Note: Turn on configuration option: isDownloadFileAttachmentsEnabled

Case 1

  1. Upload a file attachment (e.g. txt file)
    Result: download icon appears after uploading

Case 2

  1. Open a channel with attachments
  2. Tap on the download icon
  3. Tap on the share icon
  4. Save the file and also add it to notes.
    Result: Attachment file appears in the Notes app and Files app.

Case 3

  1. Download some attachments
  2. Debug command > "Delete Downloaded Attachments"
    Result: Attachment views update to show download icon instead of share icon and the file can be downloaded again.

Case 4

  1. Download some attachments
  2. Log out and log in with the same account
  3. Open a channel where attachments were downloaded in step 1
    Result: Attachments show download icon because logout deletes local downloads

☑️ 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
  • Comparison screenshots added for visual changes
  • Affected documentation updated (docusaurus, tutorial, CMS)

🎁 Meme

Provide a funny gif or image that relates to your work on this pull request. (Optional)

@laevandus laevandus added 🔧 WIP A PR that is Work in Progress 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK ✅ Feature An issue or PR related to a feature 🏗 Missing Feature Parity A feature that is not yet available on the iOS SDK. labels Aug 22, 2024
@laevandus laevandus requested a review from a team as a code owner August 22, 2024 12:38
Copy link

github-actions bot commented Aug 22, 2024

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@laevandus laevandus force-pushed the feature/file-downloads branch 3 times, most recently from 19562ca to 8af3297 Compare August 22, 2024 13:38
@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Aug 22, 2024

SDK Size

title develop branch diff status
StreamChat 6.76 MB 6.82 MB +55 KB 🟢
StreamChatUI 4.41 MB 4.42 MB +2 KB 🟢

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.

Looks good 👍 Added few comments.

Sources/StreamChat/Extensions/Task+Extensions.swift Outdated Show resolved Hide resolved
Sources/StreamChat/APIClient/APIClient.swift Outdated Show resolved Hide resolved
Sources/StreamChat/StateLayer/Chat.swift Outdated Show resolved Hide resolved
…alid only when downloading has been finished
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.

The new methods look good 👍 Additionally, we need to update the changelog, show some examples in the docs and write some tests.

Copy link
Member

@nuno-vieira nuno-vieira left a 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

@laevandus laevandus changed the title Download and share attachments [WIP] Download and share attachments Aug 27, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@nuno-vieira nuno-vieira left a 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 👍

Copy link
Member

@nuno-vieira nuno-vieira left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

@laevandus laevandus added the 🤞 Ready For QA A PR that is Ready for QA label Aug 28, 2024
@laevandus laevandus changed the title [WIP] Download and share attachments Download and share attachments Aug 28, 2024
@testableapple testableapple added 🧪 QAing and removed 🤞 Ready For QA A PR that is Ready for QA labels Aug 30, 2024
@testableapple testableapple added 🟢 QAed A PR that was QAed and removed 🧪 QAing labels Aug 30, 2024
@laevandus laevandus enabled auto-merge (squash) August 30, 2024 12:01
Copy link

sonarcloud bot commented Aug 30, 2024

@laevandus laevandus merged commit 16ae812 into develop Aug 30, 2024
15 checks passed
@laevandus laevandus deleted the feature/file-downloads branch August 30, 2024 12:47
This was referenced Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Feature An issue or PR related to a feature 🏗 Missing Feature Parity A feature that is not yet available on the iOS SDK. 🟢 QAed A PR that was QAed 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants