Skip to content

Commit bcdf40b

Browse files
committed
Merge branch 'develop' into swift-6
2 parents 5631542 + 29d6225 commit bcdf40b

File tree

6 files changed

+39
-28
lines changed

6 files changed

+39
-28
lines changed

.gitattributes

Lines changed: 0 additions & 5 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
## StreamChat
77
### 🐞 Fixed
88
- Fix swipe to reply enabled when quoting a message is disabled [#3662](https://github.com/GetStream/stream-chat-swift/pull/3662)
9+
- Fix shadowed messages increasing the channel messages unread count [#3665](https://github.com/GetStream/stream-chat-swift/pull/3665)
910

1011
# [4.78.0](https://github.com/GetStream/stream-chat-swift/releases/tag/4.78.0)
1112
_April 24, 2025_

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
66

77
gem 'danger', group: :danger_dependencies
88
gem 'fastlane', group: :fastlane_dependencies
9-
gem 'jazzy'
109
gem 'json'
1110
gem 'rubocop', '1.38', group: :rubocop_dependencies
1211
gem 'sinatra', group: :sinatra_dependencies

Gemfile.lock

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,6 @@ GEM
266266
mutex_m
267267
i18n (1.14.7)
268268
concurrent-ruby (~> 1.0)
269-
jazzy (0.15.3)
270-
cocoapods (~> 1.5)
271-
mustache (~> 1.1)
272-
open4 (~> 1.3)
273-
redcarpet (~> 3.4)
274-
rexml (>= 3.2.7, < 4.0)
275-
rouge (>= 2.0.6, < 5.0)
276-
sassc (~> 2.1)
277-
sqlite3 (~> 1.3)
278-
xcinvoke (~> 0.3.0)
279269
jmespath (1.6.2)
280270
json (2.11.3)
281271
jwt (2.10.1)
@@ -284,7 +274,6 @@ GEM
284274
rexml (>= 3.3.9)
285275
kramdown-parser-gfm (1.1.0)
286276
kramdown (~> 2.0)
287-
liferaft (0.0.6)
288277
logger (1.7.0)
289278
method_source (1.1.0)
290279
mini_magick (4.13.2)
@@ -294,7 +283,6 @@ GEM
294283
molinillo (0.8.0)
295284
multi_json (1.15.0)
296285
multipart-post (2.4.1)
297-
mustache (1.1.1)
298286
mustermann (3.0.3)
299287
ruby2_keywords (~> 0.0.1)
300288
mutex_m (0.3.0)
@@ -329,20 +317,19 @@ GEM
329317
puma (6.6.0)
330318
nio4r (~> 2.0)
331319
racc (1.8.1)
332-
rack (3.1.13)
320+
rack (3.1.14)
333321
rack-protection (4.1.1)
334322
base64 (>= 0.1.0)
335323
logger (>= 1.6.0)
336324
rack (>= 3.0.0, < 4)
337-
rack-session (2.1.0)
325+
rack-session (2.1.1)
338326
base64 (>= 0.1.0)
339327
rack (>= 3.0.0)
340328
rackup (2.2.1)
341329
rack (>= 3)
342330
rainbow (3.1.1)
343331
rake (13.2.1)
344332
rchardet (1.9.0)
345-
redcarpet (3.6.1)
346333
regexp_parser (2.10.0)
347334
representable (3.2.0)
348335
declarative (< 0.1.0)
@@ -373,8 +360,6 @@ GEM
373360
ruby-progressbar (1.13.0)
374361
ruby2_keywords (0.0.5)
375362
rubyzip (2.4.1)
376-
sassc (2.4.0)
377-
ffi (~> 1.9)
378363
sawyer (0.9.2)
379364
addressable (>= 2.3.5)
380365
faraday (>= 0.17.3, < 3)
@@ -402,8 +387,6 @@ GEM
402387
nokogiri (>= 1.14.3)
403388
xcodeproj (~> 1.27)
404389
sorbet-runtime (0.5.12043)
405-
sqlite3 (1.7.3)
406-
mini_portile2 (~> 2.8.0)
407390
stream-chat-ruby (3.0.0)
408391
faraday
409392
faraday-multipart
@@ -432,8 +415,6 @@ GEM
432415
websocket-extensions (>= 0.1.0)
433416
websocket-extensions (0.1.5)
434417
word_wrap (1.0.0)
435-
xcinvoke (0.3.0)
436-
liferaft (~> 0.0.6)
437418
xcodeproj (1.27.0)
438419
CFPropertyList (>= 2.3.3, < 4.0)
439420
atomos (~> 0.1.3)
@@ -462,7 +443,6 @@ DEPENDENCIES
462443
fastlane-plugin-stream_actions (= 0.3.79)
463444
fastlane-plugin-versioning
464445
faye-websocket
465-
jazzy
466446
json
467447
plist
468448
puma

Sources/StreamChat/WebSocketClient/EventMiddlewares/ChannelReadUpdaterMiddleware.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ struct ChannelReadUpdaterMiddleware: EventMiddleware {
222222
return .messageIsSystem
223223
}
224224

225+
if message.isShadowed {
226+
return .messageIsShadowed
227+
}
228+
225229
if message.createdAt <= channelRead.lastReadAt.bridgeDate {
226230
return .messageIsSeen
227231
}
@@ -237,6 +241,7 @@ private enum UnreadSkippingReason: CustomStringConvertible {
237241
case messageIsSilent
238242
case messageIsThreadReply
239243
case messageIsSystem
244+
case messageIsShadowed
240245
case messageIsSeen
241246
case messageIsSoftDeleted
242247

@@ -254,6 +259,8 @@ private enum UnreadSkippingReason: CustomStringConvertible {
254259
return "Thread replies do not affect unread counts"
255260
case .messageIsSystem:
256261
return "System messages do not affect unread counts"
262+
case .messageIsShadowed:
263+
return "Shadowed messages do not affect unread counts"
257264
case .messageIsSeen:
258265
return "Seen messages do not affect unread counts"
259266
case .messageIsSoftDeleted:

Tests/StreamChatTests/WebSocketClient/EventMiddlewares/ChannelReadUpdaterMiddleware_Tests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,35 @@ final class ChannelReadUpdaterMiddleware_Tests: XCTestCase {
591591
XCTAssertEqual(Int(read.unreadMessageCount), currentUserReadPayload.unreadMessagesCount)
592592
}
593593

594+
func test_messageNewEvent_whenMessageIsShadowed_doesNotIncrementUnreadCount() throws {
595+
// WHEN
596+
let shadowedMessage: MessagePayload = .dummy(
597+
type: .regular,
598+
messageId: .unique,
599+
authorUserId: anotherUserPayload.id,
600+
createdAt: currentUserReadPayload.lastReadAt.addingTimeInterval(1),
601+
isShadowed: true
602+
)
603+
604+
let messageNewEvent = try MessageNewEventDTO(
605+
from: .init(
606+
eventType: .messageNew,
607+
cid: channelPayload.channel.cid,
608+
user: anotherUserPayload,
609+
message: shadowedMessage,
610+
createdAt: shadowedMessage.createdAt
611+
)
612+
)
613+
614+
try database.writeSynchronously { session in
615+
_ = self.middleware.handle(event: messageNewEvent, session: session)
616+
}
617+
618+
// THEN
619+
let read = try XCTUnwrap(currentUserReadDTO)
620+
XCTAssertEqual(Int(read.unreadMessageCount), currentUserReadPayload.unreadMessagesCount)
621+
}
622+
594623
func test_messageNewEvent_whenMessageIsRead_doesNotIncrementUnreadCount() throws {
595624
// WHEN
596625
let regularMessageEarlierThanLastRead: MessagePayload = .dummy(

0 commit comments

Comments
 (0)