Skip to content

Commit

Permalink
[FIX] Allowed nullable MessageList/menuContent
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaesung Lee committed Mar 17, 2023
1 parent c2d9538 commit 73ce77b
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions Sources/ChatUI/ChatInChannel/MessageList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public struct MessageList<MessageType: MessageProtocol & Identifiable, RowConten
showsDate: Bool = false, // TODO: Not Supported yet
reactionItems: [String] = [],
@ViewBuilder rowContent: @escaping (_ message: MessageType) -> RowContent,
@ViewBuilder menuContent: @escaping (_ message: MessageType) -> MenuContent
menuContent: ((_ message: MessageType) -> MenuContent)? = nil
) {
var sendingMessages: [MessageType] = []
var failedMessages: [MessageType] = []
Expand Down Expand Up @@ -312,14 +312,37 @@ public struct MessageList<MessageType: MessageProtocol & Identifiable, RowConten
reactionItems: [String] = [],
@ViewBuilder rowContent: @escaping (_ message: MessageType) -> RowContent
) where MenuContent == EmptyView {
self.init(
messageData,
showsDate: showsDate,
reactionItems: reactionItems,
rowContent: rowContent
) { _ in
EmptyView()
var sendingMessages: [MessageType] = []
var failedMessages: [MessageType] = []
var sentMessages: [MessageType] = []
var deliveredMessages: [MessageType] = []
var seenMessages: [MessageType] = []

messageData.forEach {
switch $0.readReceipt {
case .sending:
sendingMessages.append($0)
case .failed:
failedMessages.append($0)
case .sent:
sentMessages.append($0)
case .delivered:
deliveredMessages.append($0)
case .seen, .played:
seenMessages.append($0)
}
}

self.sendingMessages = sendingMessages
self.failedMessages = failedMessages
self.sentMessages = sentMessages
self.deliveredMessages = deliveredMessages
self.seenMessages = seenMessages

self.showsDate = showsDate
self.rowContent = rowContent
self.reactionItems = reactionItems
self.messageMenuContent = nil
}

var sendingMessageList: some View {
Expand Down

0 comments on commit 73ce77b

Please sign in to comment.