Skip to content

Commit 65a9211

Browse files
committed
Use latestVotes order directly from LLC
1 parent c6eca07 commit 65a9211

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct PollOptionView: View {
215215
if !alternativeStyle, viewModel.showVoterAvatars {
216216
HStack(spacing: -4) {
217217
ForEach(
218-
option.latestVotes.sorted(by: { $0.createdAt > $1.createdAt }).suffix(2)
218+
option.latestVotes.prefix(2)
219219
) { vote in
220220
MessageAvatarView(
221221
avatarURL: vote.user?.imageURL,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct PollResultsView: View {
4545
poll: viewModel.poll,
4646
option: option,
4747
votes: Array(
48-
option.latestVotes.sorted(by: { $0.createdAt > $1.createdAt })
48+
option.latestVotes
4949
.prefix(numberOfItemsShown)
5050
),
5151
hasMostVotes: viewModel.hasMostVotes(for: option),

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ extension ChatChannel {
360360
private func pollMessageText(for previewMessage: ChatMessage) -> String? {
361361
guard let poll = previewMessage.poll, !previewMessage.isDeleted else { return nil }
362362
var components = ["📊"]
363-
if let latestVoter = poll.latestVotes.last?.user {
363+
if let latestVoter = poll.latestVotes.first?.user {
364364
if latestVoter.id == membership?.id {
365365
components.append(L10n.Channel.Item.pollYouVoted)
366366
} else {

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,8 +3720,8 @@
37203720
isa = XCRemoteSwiftPackageReference;
37213721
repositoryURL = "https://github.com/GetStream/stream-chat-swift.git";
37223722
requirement = {
3723-
branch = "add/polls-ui-base";
3724-
kind = branch;
3723+
kind = revision;
3724+
revision = 12aa7994b834d352423b2b1670cfe0c4b2082cc7;
37253725
};
37263726
};
37273727
E3A1C01A282BAC66002D1E26 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {

StreamChatSwiftUITests/Tests/ChatChannelList/ChatChannelListItemView_Tests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ final class ChatChannelListItemView_Tests: StreamChatTestCase {
157157
// Given
158158
let currentUserId = UserId.unique
159159
let message = try mockPollMessage(isSentByCurrentUser: false, latestVotes: [
160+
.mock(pollId: .unique, optionId: .unique, user: .mock(id: currentUserId)),
160161
.unique,
161-
.unique,
162-
.mock(pollId: .unique, optionId: .unique, user: .mock(id: currentUserId))
162+
.unique
163163
])
164164
let channel = ChatChannel.mock(cid: .unique, membership: .mock(id: currentUserId), latestMessages: [message])
165165

@@ -181,9 +181,9 @@ final class ChatChannelListItemView_Tests: StreamChatTestCase {
181181
// Given
182182
let currentUserId = UserId.unique
183183
let message = try mockPollMessage(isSentByCurrentUser: false, latestVotes: [
184+
.mock(pollId: .unique, optionId: .unique, user: .mock(id: .unique, name: "Steve Jobs")),
184185
.unique,
185-
.mock(pollId: .unique, optionId: .unique, user: .mock(id: currentUserId)),
186-
.mock(pollId: .unique, optionId: .unique, user: .mock(id: .unique, name: "Steve Jobs"))
186+
.mock(pollId: .unique, optionId: .unique, user: .mock(id: currentUserId))
187187
])
188188
let channel = ChatChannel.mock(cid: .unique, membership: .mock(id: currentUserId), latestMessages: [message])
189189

0 commit comments

Comments
 (0)