Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add `ColorPalette.navigationBarTitle`, `ColorPalette.navigationBarSubtitle`, `ColorPalette.navigationBarTintColor`, `ColorPalette.navigationBarBackground` [#939](https://github.com/GetStream/stream-chat-swiftui/pull/939)
### 🐞 Fixed
- Long message with a link preview was truncated sometimes [#940](https://github.com/GetStream/stream-chat-swiftui/pull/940)
- Fix quoted message shown in the composer when editing a quoting message [#943](https://github.com/GetStream/stream-chat-swiftui/pull/943)

# [4.87.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.87.0)
_September 01, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ open class MessageComposerViewModel: ObservableObject {
return
}

fillComposer(with: message)
text = message.text
mentionedUsers = message.mentionedUsers
showReplyInChannel = message.showReplyInChannel
selectedRangeLocation = message.text.count
attachmentsConverter.attachmentsToAssets(message.allAttachments) { [weak self] assets in
self?.updateComposerAssets(assets)
}
}

/// Populates the draft message in the composer with the current controller's draft information.
Expand All @@ -290,7 +296,15 @@ open class MessageComposerViewModel: ObservableObject {
return
}

fillComposer(with: ChatMessage(draft))
let message = ChatMessage(draft)
text = message.text
mentionedUsers = message.mentionedUsers
quotedMessage?.wrappedValue = message.quotedMessage
showReplyInChannel = message.showReplyInChannel
selectedRangeLocation = message.text.count
attachmentsConverter.attachmentsToAssets(message.allAttachments) { [weak self] assets in
self?.updateComposerAssets(assets)
}
}

/// Updates the draft message locally and on the server.
Expand Down Expand Up @@ -642,18 +656,6 @@ open class MessageComposerViewModel: ObservableObject {

// MARK: - private

private func fillComposer(with message: ChatMessage) {
text = message.text
mentionedUsers = message.mentionedUsers
quotedMessage?.wrappedValue = message.quotedMessage
showReplyInChannel = message.showReplyInChannel
selectedRangeLocation = message.text.count

attachmentsConverter.attachmentsToAssets(message.allAttachments) { [weak self] assets in
self?.updateComposerAssets(assets)
}
}

private func updateComposerAssets(_ assets: ComposerAssets) {
addedAssets = assets.mediaAssets
addedFileURLs = assets.fileAssets.map(\.url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,22 @@ class MessageComposerView_Tests: StreamChatTestCase {
AssertSnapshot(view, variants: [.defaultLight], size: size)
}

func test_composerView_editingMessageWithQuotedMessage() {
let size = CGSize(width: defaultScreenSize.width, height: 100)
let mockEditedMessage = ChatMessage.mock(
id: .unique,
cid: .unique,
text: "This is a message being edited",
author: .mock(id: .unique),
quotedMessage: .mock(text: "Should not appear")
)

let view = makeComposerViewWithEditedMessage(mockEditedMessage)
.frame(width: size.width, height: size.height)

AssertSnapshot(view, variants: [.defaultLight], size: size)
}

func test_composerView_editingMessageWithImageAttachment() throws {
let size = CGSize(width: defaultScreenSize.width, height: 200)
let mockEditedMessage = ChatMessage.mock(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading