File tree Expand file tree Collapse file tree 4 files changed +10
-17
lines changed
StreamChatCoreTests/Integration Tests Expand file tree Collapse file tree 4 files changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public extension Client {
1919 /// - eventType: an event type.
2020 /// - channelId: a channeld id (optional).
2121 /// - Returns: an observable event.
22- func onEvent( _ eventType: EventType ? = nil , for channelId: String ? = nil ) -> Observable < Event > {
22+ func onEvent( _ eventType: EventType ? = nil , channelId: String ? = nil ) -> Observable < Event > {
2323 return webSocket. response
2424 . filter {
2525 if let channelId = channelId {
Original file line number Diff line number Diff line change @@ -181,8 +181,14 @@ public struct Message: Codable {
181181 replyCount = try container. decode ( Int . self, forKey: . replyCount)
182182 latestReactions = try container. decode ( [ Reaction ] . self, forKey: . latestReactions)
183183 ownReactions = try container. decode ( [ Reaction ] . self, forKey: . ownReactions)
184- reactionCounts = try container. decodeIfPresent ( ReactionCounts . self, forKey: . reactionCounts)
185184 extraData = . decode( from: decoder, ExtraData . decodableTypes. first ( where: { $0. isMessage } ) )
185+
186+ if let reactionCounts = try container. decodeIfPresent ( ReactionCounts . self, forKey: . reactionCounts) ,
187+ !reactionCounts. counts. isEmpty {
188+ self . reactionCounts = reactionCounts
189+ } else {
190+ reactionCounts = nil
191+ }
186192 }
187193
188194 private func checkIfTextAsAttachmentURL( _ text: String ) -> Bool {
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ public final class ChannelPresenter: Presenter<ChatItem> {
106106 . filter { $0 != . none }
107107 . asDriver { Driver . just ( ViewChanges . error ( AnyError ( error: $0) ) ) }
108108
109- private lazy var webSocketChanges : Driver < ViewChanges > = channel . onEvent ( )
109+ private lazy var webSocketChanges : Driver < ViewChanges > = Client . shared . onEvent ( channelId : channelId )
110110 . map { [ weak self] in self ? . parseChanges ( event: $0) ?? . none }
111111 . filter { $0 != . none }
112112 . map { [ weak self] in self ? . mapWithEphemeralMessage ( $0) ?? . none }
@@ -215,7 +215,7 @@ extension ChannelPresenter {
215215
216216 if let messageNewChannel = messageNewChannel {
217217 channelMVar. set ( messageNewChannel)
218- }
218+ }
219219
220220 if channel. config. readEventsEnabled {
221221 if let lastMessage = lastMessageMVar. get ( ) {
Original file line number Diff line number Diff line change @@ -98,19 +98,6 @@ final class ChannelTests: TestCase {
9898 return nil
9999 }
100100 . unwrap ( )
101- . flatMapLatest { $0. deleteReaction ( . like) }
102- . map { response -> Message ? in
103- if let reactionCounts = response. message. reactionCounts {
104- XCTAssertEqual ( reactionCounts. counts, [ ReactionType . love: 1 ] )
105- XCTAssertEqual ( reactionCounts. string, " \( ReactionType . love. emoji) 1 " )
106- return response. message
107- }
108-
109- XCTFail ( " Failed to delete a reaction " )
110-
111- return nil
112- }
113- . unwrap ( )
114101 . flatMapLatest { $0. deleteReaction ( . love) }
115102 . map { response -> Message ? in
116103 XCTAssertNil ( response. message. reactionCounts)
You can’t perform that action at this time.
0 commit comments