Skip to content

Add extra data to user display info #819

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2025
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Upcoming

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

# [4.78.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.78.0)
_April 24, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ struct AddUsersView<Factory: ViewFactory>: View {
id: user.id,
name: user.name ?? "",
imageURL: user.imageURL,
size: CGSize(width: itemSize, height: itemSize)
size: CGSize(width: itemSize, height: itemSize),
extraData: user.extraData
)
factory.makeMessageAvatarView(for: userDisplayInfo)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ struct ChatInfoDirectChannelView<Factory: ViewFactory>: View {
id: participant?.chatUser.id ?? "",
name: participant?.chatUser.name ?? "",
imageURL: participant?.chatUser.imageURL,
size: .init(width: 64, height: 64)
size: .init(width: 64, height: 64),
extraData: participant?.chatUser.extraData ?? [:]
)
factory.makeMessageAvatarView(for: displayInfo)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct ChatInfoParticipantsView<Factory: ViewFactory>: View {
let displayInfo = UserDisplayInfo(
id: participant.chatUser.id,
name: participant.chatUser.name ?? "",
imageURL: participant.chatUser.imageURL
imageURL: participant.chatUser.imageURL,
extraData: participant.chatUser.extraData
)
factory.makeMessageAvatarView(for: displayInfo)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public struct MediaAttachmentsView<Factory: ViewFactory>: View {
id: mediaItem.message.author.id,
name: mediaItem.message.author.name ?? "",
imageURL: mediaItem.message.author.imageURL,
size: .init(width: 24, height: 24)
size: .init(width: 24, height: 24),
extraData: mediaItem.message.author.extraData
)
)
.overlay(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ struct PinnedMessageView<Factory: ViewFactory>: View {
id: message.author.id,
name: message.author.name ?? "",
imageURL: message.author.imageURL,
size: avatarSize
size: avatarSize,
extraData: message.author.extraData
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ struct PollOptionView<Factory: ViewFactory>: View {
id: vote.user?.id ?? "",
name: vote.user?.name ?? "",
imageURL: vote.user?.imageURL,
size: .init(width: 20, height: 20)
size: .init(width: 20, height: 20),
extraData: vote.user?.extraData ?? [:]
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ struct PollCommentsView<Factory: ViewFactory>: View {
let displayInfo = UserDisplayInfo(
id: comment.user?.id ?? "",
name: comment.user?.name ?? "",
imageURL: comment.user?.imageURL
imageURL: comment.user?.imageURL,
extraData: comment.user?.extraData ?? [:]
)
factory.makeMessageAvatarView(for: displayInfo)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ struct PollOptionResultsView<Factory: ViewFactory>: View {
id: vote.user?.id ?? "",
name: vote.user?.name ?? "",
imageURL: vote.user?.imageURL,
size: .init(width: 20, height: 20)
size: .init(width: 20, height: 20),
extraData: vote.user?.extraData ?? [:]
)
)
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/StreamChatSwiftUI/Utils/MessageCachingUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ public struct UserDisplayInfo {
public let imageURL: URL?
public let role: UserRole?
public let size: CGSize?
public let extraData: [String: RawJSON]

public init(
id: String,
name: String,
imageURL: URL?,
role: UserRole? = nil,
size: CGSize? = nil
size: CGSize? = nil,
extraData: [String: RawJSON] = [:]
) {
self.id = id
self.name = name
self.imageURL = imageURL
self.role = role
self.size = size
self.extraData = extraData
}
}

Expand All @@ -57,7 +60,8 @@ extension ChatMessage {
id: author.id,
name: author.name ?? author.id,
imageURL: author.imageURL,
role: author.userRole
role: author.userRole,
extraData: author.extraData
)
}

Expand Down
Loading