|
4 | 4 |
|
5 | 5 | import StreamChat
|
6 | 6 |
|
| 7 | +/// Data source providing the chat messages. |
7 | 8 | protocol MessagesDataSource: AnyObject {
|
8 | 9 |
|
| 10 | + /// Called when the messages are updated. |
| 11 | + /// |
| 12 | + /// - Parameters: |
| 13 | + /// - channelDataSource, the channel's data source. |
| 14 | + /// - messages, the collection of updated messages. |
9 | 15 | func dataSource(
|
10 | 16 | channelDataSource: ChannelDataSource,
|
11 | 17 | didUpdateMessages messages: LazyCachedMapCollection<ChatMessage>
|
12 | 18 | )
|
13 | 19 |
|
| 20 | + /// Called when the channel is updated. |
| 21 | + /// - Parameters: |
| 22 | + /// - channelDataSource: the channel's data source. |
| 23 | + /// - channel: the updated channel. |
| 24 | + /// - channelController: the channel's controller. |
14 | 25 | func dataSource(
|
15 | 26 | channelDataSource: ChannelDataSource,
|
16 | 27 | didUpdateChannel channel: EntityChange<ChatChannel>,
|
17 | 28 | channelController: ChatChannelController
|
18 | 29 | )
|
19 | 30 | }
|
20 | 31 |
|
| 32 | +/// The data source for the channel. |
21 | 33 | protocol ChannelDataSource: AnyObject {
|
22 | 34 |
|
| 35 | + /// Delegate implementing the `MessagesDataSource`. |
23 | 36 | var delegate: MessagesDataSource? { get set }
|
24 | 37 |
|
| 38 | + /// List of the messages. |
25 | 39 | var messages: LazyCachedMapCollection<ChatMessage> { get }
|
26 | 40 |
|
| 41 | + /// Loads the previous messages. |
| 42 | + /// - Parameters: |
| 43 | + /// - messageId: the id of the last received message. |
| 44 | + /// - limit: the max number of messages to be retrieved. |
| 45 | + /// - completion: called when the messages are loaded. |
27 | 46 | func loadPreviousMessages(
|
28 | 47 | before messageId: MessageId?,
|
29 | 48 | limit: Int,
|
30 | 49 | completion: ((Error?) -> Void)?
|
31 | 50 | )
|
32 | 51 | }
|
33 | 52 |
|
| 53 | +/// Implementation of `ChannelDataSource`. Loads the messages of the channel. |
34 | 54 | class ChatChannelDataSource: ChannelDataSource, ChatChannelControllerDelegate {
|
35 | 55 |
|
36 | 56 | let controller: ChatChannelController
|
@@ -78,6 +98,7 @@ class ChatChannelDataSource: ChannelDataSource, ChatChannelControllerDelegate {
|
78 | 98 | }
|
79 | 99 | }
|
80 | 100 |
|
| 101 | +/// Implementation of the `ChannelDataSource`. Loads the messages in a reply thread. |
81 | 102 | class MessageThreadDataSource: ChannelDataSource, ChatMessageControllerDelegate {
|
82 | 103 |
|
83 | 104 | let channelController: ChatChannelController
|
|
0 commit comments