-
Notifications
You must be signed in to change notification settings - Fork 121
feat(chat): Group the files of one upload into a single message #2705
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ivansss
wants to merge
8
commits into
main
Choose a base branch
from
feat/noid/group-file-messages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
539ba29
feat(chat): Write reference ids that identify files shared together
Ivansss 28ddcb0
fix(upload): Post messages for files shared together in order
Ivansss 113a886
chore(chat): Add the grouping of files shared as one upload
Ivansss 32449c2
feat(chat): Show the files of one upload as a single message
Ivansss cf03eef
feat(chat): Make the files of a group tappable cards that show progress
Ivansss a031e01
fix(chat): Correct the measured height of a grouped file message
Ivansss a80e001
feat(chat): Draw files without a preview on a card on their own
Ivansss d82a859
refactor(chat): Parse the reference id with a regular expression
Ivansss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
NextcloudTalk/Chat/Chat cells/BaseChatTableViewCell+FileGroup.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // | ||
| // SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| extension BaseChatTableViewCell { | ||
|
|
||
| func setupForFileGroupCell(with group: FileMessageGroup, with account: TalkAccount) { | ||
| if self.groupedFilePreviewView == nil { | ||
| let groupedFilePreviewView = GroupedFilePreviewView() | ||
| self.groupedFilePreviewView = groupedFilePreviewView | ||
|
|
||
| groupedFilePreviewView.translatesAutoresizingMaskIntoConstraints = false | ||
| groupedFilePreviewView.delegate = self | ||
| groupedFilePreviewView.accessibilityIdentifier = "groupedFilePreviewView" | ||
|
|
||
| self.messageBodyView.addSubview(groupedFilePreviewView) | ||
|
|
||
| let messageTextView = MessageBodyTextView() | ||
| self.messageTextView = messageTextView | ||
|
|
||
| messageTextView.translatesAutoresizingMaskIntoConstraints = false | ||
|
|
||
| self.messageBodyView.addSubview(messageTextView) | ||
|
|
||
| // Without a caption the text view is taken out of the layout entirely. Hiding it is not | ||
| // enough: an empty text view still takes its line height, which would make the body | ||
| // taller than the cell was measured to be, and everything below it stops taking taps. | ||
| self.fileGroupCaptionConstraints = [ | ||
| messageTextView.topAnchor.constraint(equalTo: groupedFilePreviewView.bottomAnchor, constant: 10), | ||
| messageTextView.bottomAnchor.constraint(equalTo: self.messageBodyView.bottomAnchor) | ||
| ] | ||
|
|
||
| self.fileGroupWithoutCaptionConstraint = groupedFilePreviewView.bottomAnchor.constraint(equalTo: self.messageBodyView.bottomAnchor) | ||
|
|
||
| NSLayoutConstraint.activate([ | ||
| groupedFilePreviewView.leftAnchor.constraint(equalTo: self.messageBodyView.leftAnchor), | ||
| groupedFilePreviewView.topAnchor.constraint(equalTo: self.messageBodyView.topAnchor), | ||
| groupedFilePreviewView.rightAnchor.constraint(lessThanOrEqualTo: self.messageBodyView.rightAnchor), | ||
| messageTextView.leftAnchor.constraint(equalTo: self.messageBodyView.leftAnchor), | ||
| messageTextView.rightAnchor.constraint(equalTo: self.messageBodyView.rightAnchor) | ||
| ]) | ||
| } | ||
|
|
||
| guard let groupedFilePreviewView = self.groupedFilePreviewView, | ||
| let messageTextView = self.messageTextView | ||
| else { return } | ||
|
|
||
| groupedFilePreviewView.setup(with: group, account: account, availableWidth: self.availableBodyWidth) | ||
|
|
||
| // The caption is carried by the file shared last, which is what the group is shown as | ||
| let hasCaption = !group.anchor.sharesFileWithoutCaption | ||
|
|
||
| messageTextView.isHidden = !hasCaption | ||
| messageTextView.attributedText = hasCaption ? group.anchor.parsedMarkdownForChat() : nil | ||
| messageTextView.dataDetectorTypes = hasCaption ? .all : [] | ||
|
|
||
| self.fileGroupWithoutCaptionConstraint?.isActive = false | ||
| NSLayoutConstraint.deactivate(self.fileGroupCaptionConstraints) | ||
|
|
||
| if hasCaption { | ||
| NSLayoutConstraint.activate(self.fileGroupCaptionConstraints) | ||
| } else { | ||
| self.fileGroupWithoutCaptionConstraint?.isActive = true | ||
| } | ||
| } | ||
|
|
||
| func prepareForReuseFileGroupCell() { | ||
| self.groupedFilePreviewView?.prepareForReuse() | ||
| } | ||
| } | ||
|
|
||
| extension BaseChatTableViewCell: GroupedFilePreviewViewDelegate { | ||
|
|
||
| func groupedFilePreviewView(_ view: GroupedFilePreviewView, didSelectFileAt index: Int) { | ||
| guard let messages = self.fileGroup?.messagesInUploadOrder, index < messages.count else { return } | ||
|
|
||
| let message = messages[index] | ||
|
|
||
| guard let file = message.file(), file.path != nil else { return } | ||
|
|
||
| self.delegate?.cellWants(toDownloadFile: file, for: message) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I wonder if we can rely on that entirely? It鈥檚 up to the uploading client, isn鈥檛 it?
What happens with old clients? What happens with reaction on individual messages or captions (which is possible on old clients and api in general).
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.
It is up to the client yes, but if the client is sending the group reference id (supporting grouping feature) I think we can assume the caption will be on the last message.
This is a current issue, at the moment only the reactions of the last message of the group will be shown.
nextcloud/spreed#19371
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.
But if the API/old clients can edit message in between, that's still an issue?