-
Notifications
You must be signed in to change notification settings - Fork 229
Mark messages as unread using timestamp #3885
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
base: develop
Are you sure you want to change the base?
Changes from all commits
03a0661
205b37e
fd9bbb3
095fb8a
a7f68db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // | ||
| // Copyright © 2025 Stream.io Inc. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum MarkUnreadCriteria: Sendable, Equatable { | ||
| /// The ID of the message from where the channel is marked unread | ||
| case messageId(String) | ||
| /// The timestamp of the message from where the channel is marked unread | ||
| case messageTimestamp(Date) | ||
| } | ||
laevandus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| struct MarkUnreadPayload: Encodable, Sendable { | ||
| let criteria: MarkUnreadCriteria | ||
| let userId: String | ||
|
|
||
| func encode(to encoder: any Encoder) throws { | ||
| var container = encoder.container(keyedBy: CodingKeys.self) | ||
| try container.encode(userId, forKey: .userId) | ||
| switch criteria { | ||
| case .messageId(let messageId): | ||
| try container.encode(messageId, forKey: .messageId) | ||
| case .messageTimestamp(let messageTimestamp): | ||
| try container.encode(messageTimestamp, forKey: .messageTimestamp) | ||
| } | ||
| } | ||
|
|
||
| private enum CodingKeys: String, CodingKey { | ||
| case messageId = "message_id" | ||
| case messageTimestamp = "message_timestamp" | ||
| case userId = "user_id" | ||
| } | ||
| } | ||
laevandus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -598,6 +598,10 @@ open class ChatChannelVC: _ViewController, | |
| if let event = event as? MessageDeliveredEvent, event.cid == channelController.cid, !messages.isEmpty { | ||
| messageListVC.listView.reloadRows(at: [.init(item: 0, section: 0)], with: .none) | ||
| } | ||
|
|
||
| if let event = event as? NotificationMarkUnreadEvent, let channel = channelController.channel, event.cid == channelController.cid, !messages.isEmpty { | ||
| updateAllUnreadMessagesRelatedComponents(channel: channel) | ||
| } | ||
|
Comment on lines
+602
to
+604
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing mark unread message action is implemented in case is MarkUnreadActionItem:
dismiss(animated: true) { [weak self] in
self?.channelController.markUnread(from: message.id) { result in
if case let .success(channel) = result {
self?.updateAllUnreadMessagesRelatedComponents(channel: channel)
}
}
}
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's ok imo, we have one sample implementation (customers can change/decide which one to use). |
||
| } | ||
|
|
||
| // MARK: - AudioQueuePlayerDatasource | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.