Skip to content

Commit bcb43f4

Browse files
Add extra data to user display info (#819)
1 parent 946122d commit bcb43f4

10 files changed

+24
-11
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### ✅ Added
7+
- Add extra data to user display info [#819](https://github.com/GetStream/stream-chat-swiftui/pull/819)
78

89
# [4.78.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.78.0)
910
_April 24, 2025_

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/AddUsersView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ struct AddUsersView<Factory: ViewFactory>: View {
6565
id: user.id,
6666
name: user.name ?? "",
6767
imageURL: user.imageURL,
68-
size: CGSize(width: itemSize, height: itemSize)
68+
size: CGSize(width: itemSize, height: itemSize),
69+
extraData: user.extraData
6970
)
7071
factory.makeMessageAvatarView(for: userDisplayInfo)
7172

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoHelperViews.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ struct ChatInfoDirectChannelView<Factory: ViewFactory>: View {
264264
id: participant?.chatUser.id ?? "",
265265
name: participant?.chatUser.name ?? "",
266266
imageURL: participant?.chatUser.imageURL,
267-
size: .init(width: 64, height: 64)
267+
size: .init(width: 64, height: 64),
268+
extraData: participant?.chatUser.extraData ?? [:]
268269
)
269270
factory.makeMessageAvatarView(for: displayInfo)
270271

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
3232
let displayInfo = UserDisplayInfo(
3333
id: participant.chatUser.id,
3434
name: participant.chatUser.name ?? "",
35-
imageURL: participant.chatUser.imageURL
35+
imageURL: participant.chatUser.imageURL,
36+
extraData: participant.chatUser.extraData
3637
)
3738
factory.makeMessageAvatarView(for: displayInfo)
3839

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/MediaAttachmentsView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public struct MediaAttachmentsView<Factory: ViewFactory>: View {
8383
id: mediaItem.message.author.id,
8484
name: mediaItem.message.author.name ?? "",
8585
imageURL: mediaItem.message.author.imageURL,
86-
size: .init(width: 24, height: 24)
86+
size: .init(width: 24, height: 24),
87+
extraData: mediaItem.message.author.extraData
8788
)
8889
)
8990
.overlay(

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/PinnedMessagesView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ struct PinnedMessageView<Factory: ViewFactory>: View {
7171
id: message.author.id,
7272
name: message.author.name ?? "",
7373
imageURL: message.author.imageURL,
74-
size: avatarSize
74+
size: avatarSize,
75+
extraData: message.author.extraData
7576
)
7677
)
7778

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ struct PollOptionView<Factory: ViewFactory>: View {
228228
id: vote.user?.id ?? "",
229229
name: vote.user?.name ?? "",
230230
imageURL: vote.user?.imageURL,
231-
size: .init(width: 20, height: 20)
231+
size: .init(width: 20, height: 20),
232+
extraData: vote.user?.extraData ?? [:]
232233
)
233234
)
234235
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollCommentsView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ struct PollCommentsView<Factory: ViewFactory>: View {
4343
let displayInfo = UserDisplayInfo(
4444
id: comment.user?.id ?? "",
4545
name: comment.user?.name ?? "",
46-
imageURL: comment.user?.imageURL
46+
imageURL: comment.user?.imageURL,
47+
extraData: comment.user?.extraData ?? [:]
4748
)
4849
factory.makeMessageAvatarView(for: displayInfo)
4950
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ struct PollOptionResultsView<Factory: ViewFactory>: View {
113113
id: vote.user?.id ?? "",
114114
name: vote.user?.name ?? "",
115115
imageURL: vote.user?.imageURL,
116-
size: .init(width: 20, height: 20)
116+
size: .init(width: 20, height: 20),
117+
extraData: vote.user?.extraData ?? [:]
117118
)
118119
)
119120
}

Sources/StreamChatSwiftUI/Utils/MessageCachingUtils.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,22 @@ public struct UserDisplayInfo {
3434
public let imageURL: URL?
3535
public let role: UserRole?
3636
public let size: CGSize?
37+
public let extraData: [String: RawJSON]
3738

3839
public init(
3940
id: String,
4041
name: String,
4142
imageURL: URL?,
4243
role: UserRole? = nil,
43-
size: CGSize? = nil
44+
size: CGSize? = nil,
45+
extraData: [String: RawJSON] = [:]
4446
) {
4547
self.id = id
4648
self.name = name
4749
self.imageURL = imageURL
4850
self.role = role
4951
self.size = size
52+
self.extraData = extraData
5053
}
5154
}
5255

@@ -57,7 +60,8 @@ extension ChatMessage {
5760
id: author.id,
5861
name: author.name ?? author.id,
5962
imageURL: author.imageURL,
60-
role: author.userRole
63+
role: author.userRole,
64+
extraData: author.extraData
6165
)
6266
}
6367

0 commit comments

Comments
 (0)