diff --git a/CHANGELOG.md b/CHANGELOG.md index e3103852..c7fbb1e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### 🐞 Fixed - Smoother and more performant view updates in channel and message lists [#522](https://github.com/GetStream/stream-chat-swiftui/pull/522) - Fix scrolling location when jumping to a message not in the currently loaded message list [#533](https://github.com/GetStream/stream-chat-swiftui/pull/533) +- Fix display of the most votes icon in Polls [#538](https://github.com/GetStream/stream-chat-swiftui/pull/538) # [4.58.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.58.0) _June 27, 2024_ diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift index 71e9c38f..06870fbc 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift @@ -48,6 +48,7 @@ struct PollResultsView: View { option.latestVotes.sorted(by: { $0.createdAt > $1.createdAt }) .prefix(numberOfItemsShown) ), + hasMostVotes: viewModel.hasMostVotes(for: option), allButtonShown: option.latestVotes.count > numberOfItemsShown ) } @@ -80,6 +81,7 @@ struct PollOptionResultsView: View { var poll: Poll var option: PollOption var votes: [PollVote] + var hasMostVotes: Bool = false var allButtonShown = false var onVoteAppear: ((PollVote) -> Void)? @@ -89,10 +91,12 @@ struct PollOptionResultsView: View { Text(option.text) .font(fonts.bodyBold) Spacer() - Image(systemName: "trophy") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(height: 16) + if hasMostVotes { + Image(systemName: "trophy") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(height: 16) + } Text(L10n.Message.Polls.votes(poll.voteCountsByOption?[option.id] ?? 0)) } diff --git a/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/PollAttachmentView_Tests/test_pollAttachmentView_allVotes.1.png b/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/PollAttachmentView_Tests/test_pollAttachmentView_allVotes.1.png index ad6687f5..ff1b9939 100644 Binary files a/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/PollAttachmentView_Tests/test_pollAttachmentView_allVotes.1.png and b/StreamChatSwiftUITests/Tests/ChatChannel/__Snapshots__/PollAttachmentView_Tests/test_pollAttachmentView_allVotes.1.png differ