Skip to content

Commit

Permalink
Merge pull request #22 from jaesung-0o0/feature/jaesung/nullable-mess…
Browse files Browse the repository at this point in the history
…age-menu

[FIX] Allowed nullable `MessageList/menuContent`
  • Loading branch information
x-0o0 authored Mar 18, 2023
2 parents 20d0db5 + 73ce77b commit 65b6d6f
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 65b6d6f

Please sign in to comment.