stream-chat 10.0.0-rc.21 → 10.0.0-rc.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/dist/cjs/index.browser.js +2196 -3902
  2. package/dist/cjs/index.browser.js.map +3 -3
  3. package/dist/cjs/index.node.js +2197 -3902
  4. package/dist/cjs/index.node.js.map +3 -3
  5. package/dist/esm/index.mjs +2199 -3905
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +120 -233
  8. package/dist/types/CooldownTimer.d.ts +8 -23
  9. package/dist/types/EventHandlerPipeline.d.ts +17 -37
  10. package/dist/types/LiveLocationManager.d.ts +22 -50
  11. package/dist/types/api-client.d.ts +9 -14
  12. package/dist/types/channel.d.ts +253 -448
  13. package/dist/types/channel_state.d.ts +48 -95
  14. package/dist/types/client.d.ts +245 -370
  15. package/dist/types/client_state.d.ts +1 -3
  16. package/dist/types/configuration/ConfigController.d.ts +30 -124
  17. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
  18. package/dist/types/configuration/keys.d.ts +5 -19
  19. package/dist/types/configuration/shape.d.ts +12 -29
  20. package/dist/types/configuration/types.d.ts +59 -87
  21. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
  22. package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
  23. package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
  24. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
  25. package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
  26. package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
  27. package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
  28. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
  29. package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
  30. package/dist/types/connection/networkConnection/types.d.ts +12 -27
  31. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
  32. package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
  33. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
  34. package/dist/types/connection/wsConnection/config.d.ts +8 -28
  35. package/dist/types/connection/wsConnection/types.d.ts +17 -70
  36. package/dist/types/entityStore/EntityStore.d.ts +153 -113
  37. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
  38. package/dist/types/errors.d.ts +7 -19
  39. package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
  40. package/dist/types/gen/chat/ChatApi.d.ts +28 -14
  41. package/dist/types/gen/models/index.d.ts +769 -86
  42. package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
  43. package/dist/types/index.d.ts +2 -4
  44. package/dist/types/languageNames.d.ts +9 -24
  45. package/dist/types/logger.d.ts +1 -3
  46. package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
  47. package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
  48. package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
  49. package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
  50. package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
  51. package/dist/types/messageComposer/configuration/types.d.ts +29 -56
  52. package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
  53. package/dist/types/messageComposer/messageComposer.d.ts +30 -164
  54. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
  55. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
  56. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
  57. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
  58. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
  59. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
  60. package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
  61. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
  62. package/dist/types/messageComposer/pollComposer.d.ts +8 -4
  63. package/dist/types/messageComposer/textComposer.d.ts +3 -9
  64. package/dist/types/messageComposer/types.d.ts +5 -8
  65. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
  66. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
  67. package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
  68. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
  69. package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
  70. package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
  71. package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
  72. package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
  73. package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
  74. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
  75. package/dist/types/messageOperations/types.d.ts +15 -30
  76. package/dist/types/middleware.d.ts +7 -5
  77. package/dist/types/moderation.d.ts +21 -14
  78. package/dist/types/notifications/NotificationManager.d.ts +8 -31
  79. package/dist/types/notifications/types.d.ts +19 -59
  80. package/dist/types/offline-support/offline_support_api.d.ts +145 -539
  81. package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
  82. package/dist/types/offline-support/queueableOperations.d.ts +24 -52
  83. package/dist/types/offline-support/types.d.ts +24 -187
  84. package/dist/types/pagination/ItemIndex.d.ts +4 -12
  85. package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
  86. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
  87. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
  88. package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
  89. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
  90. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
  91. package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
  92. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
  93. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
  94. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
  95. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
  96. package/dist/types/pagination/sortCompiler.d.ts +11 -22
  97. package/dist/types/pagination/utility.normalization.d.ts +5 -23
  98. package/dist/types/pagination/utility.search.d.ts +3 -8
  99. package/dist/types/poll.d.ts +14 -14
  100. package/dist/types/poll_manager.d.ts +11 -2
  101. package/dist/types/poll_optimistic_votes.d.ts +10 -14
  102. package/dist/types/reminders/Reminder.d.ts +4 -4
  103. package/dist/types/reminders/ReminderManager.d.ts +7 -20
  104. package/dist/types/search/BaseSearchSource.d.ts +7 -12
  105. package/dist/types/search/ChannelSearchSource.d.ts +7 -7
  106. package/dist/types/search/MessageSearchSource.d.ts +7 -9
  107. package/dist/types/search/SearchController.d.ts +17 -22
  108. package/dist/types/search/types.d.ts +6 -10
  109. package/dist/types/signing.d.ts +12 -3
  110. package/dist/types/thread.d.ts +23 -71
  111. package/dist/types/thread_manager.d.ts +45 -70
  112. package/dist/types/token_manager.d.ts +8 -13
  113. package/dist/types/types.d.ts +64 -125
  114. package/dist/types/types.utility.d.ts +3 -3
  115. package/dist/types/upload-utils.d.ts +5 -10
  116. package/dist/types/uploadManager.d.ts +17 -45
  117. package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
  118. package/dist/types/utils/WithSubscriptions.d.ts +5 -15
  119. package/dist/types/utils/concurrency.d.ts +11 -19
  120. package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
  121. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
  122. package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
  123. package/dist/types/utils/objectPath.d.ts +6 -41
  124. package/dist/types/utils/retryable.d.ts +8 -12
  125. package/dist/types/utils/throttling/throttle.d.ts +8 -23
  126. package/dist/types/utils/time.d.ts +24 -64
  127. package/dist/types/utils.d.ts +40 -86
  128. package/package.json +7 -2
  129. package/src/ChannelManager.ts +159 -300
  130. package/src/CooldownTimer.ts +11 -29
  131. package/src/EventHandlerPipeline.ts +21 -44
  132. package/src/LiveLocationManager.ts +35 -74
  133. package/src/api-client.ts +43 -61
  134. package/src/campaign.ts +1 -1
  135. package/src/channel.ts +396 -749
  136. package/src/channel_batch_updater.ts +1 -1
  137. package/src/channel_state.ts +50 -105
  138. package/src/client.ts +360 -588
  139. package/src/client_state.ts +1 -6
  140. package/src/configuration/ConfigController.ts +41 -157
  141. package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
  142. package/src/configuration/index.ts +1 -1
  143. package/src/configuration/keys.ts +13 -32
  144. package/src/configuration/shape.ts +67 -70
  145. package/src/configuration/types.ts +60 -100
  146. package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
  147. package/src/configuration/utils/copyConfigPatch.ts +11 -32
  148. package/src/configuration/utils/declarativeSlices.ts +9 -39
  149. package/src/configuration/utils/deepFreezeConfig.ts +3 -17
  150. package/src/configuration/utils/index.ts +2 -4
  151. package/src/configuration/utils/serverAuthority.ts +20 -68
  152. package/src/connection/ConnectionIdManager.ts +20 -49
  153. package/src/connection/ConnectionRecoveryManager.ts +51 -178
  154. package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
  155. package/src/connection/networkConnection/reporters.ts +9 -36
  156. package/src/connection/networkConnection/types.ts +12 -27
  157. package/src/connection/wsConnection/StableWSConnection.ts +73 -193
  158. package/src/connection/wsConnection/WSConnection.ts +56 -131
  159. package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
  160. package/src/connection/wsConnection/config.ts +13 -48
  161. package/src/connection/wsConnection/types.ts +17 -70
  162. package/src/constants.ts +4 -4
  163. package/src/entityStore/EntityStore.ts +162 -167
  164. package/src/entityStore/StoreBackedItemIndex.ts +14 -47
  165. package/src/errors.ts +7 -19
  166. package/src/formatMessageMemo.ts +3 -9
  167. package/src/gen/chat/ChannelApi.ts +19 -0
  168. package/src/gen/chat/ChatApi.ts +87 -13
  169. package/src/gen/models/index.ts +793 -71
  170. package/src/gen/moderation/ModerationApi.ts +0 -4
  171. package/src/index.ts +10 -14
  172. package/src/languageNames.ts +9 -24
  173. package/src/logger.ts +1 -3
  174. package/src/messageComposer/LocationComposer.ts +7 -23
  175. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
  176. package/src/messageComposer/attachmentIdentity.ts +2 -13
  177. package/src/messageComposer/attachmentManager.ts +17 -63
  178. package/src/messageComposer/attachmentUtils.ts +3 -17
  179. package/src/messageComposer/configuration/configuration.ts +5 -8
  180. package/src/messageComposer/configuration/types.ts +29 -56
  181. package/src/messageComposer/fileUtils.ts +1 -1
  182. package/src/messageComposer/linkPreviewsManager.ts +8 -20
  183. package/src/messageComposer/messageComposer.ts +54 -222
  184. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
  185. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
  186. package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
  187. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
  188. package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
  189. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
  190. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  191. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  192. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  193. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
  194. package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
  195. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  196. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  197. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  198. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  199. package/src/messageComposer/pollComposer.ts +11 -8
  200. package/src/messageComposer/textComposer.ts +9 -59
  201. package/src/messageComposer/types.ts +9 -12
  202. package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
  203. package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
  204. package/src/messageOperations/FailedSendCache.ts +4 -9
  205. package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
  206. package/src/messageOperations/MessageOperations.ts +33 -62
  207. package/src/messageOperations/applyReactionLocally.ts +9 -28
  208. package/src/messageOperations/createMessageOperations.ts +17 -33
  209. package/src/messageOperations/reflectReactionEvent.ts +5 -13
  210. package/src/messageOperations/sendOrdering.ts +4 -7
  211. package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
  212. package/src/messageOperations/types.ts +15 -30
  213. package/src/middleware.ts +7 -10
  214. package/src/moderation.ts +25 -21
  215. package/src/notifications/NotificationManager.ts +11 -35
  216. package/src/notifications/types.ts +19 -59
  217. package/src/offline-support/offline_support_api.ts +178 -608
  218. package/src/offline-support/offline_sync_manager.ts +25 -69
  219. package/src/offline-support/queueableOperations.ts +31 -84
  220. package/src/offline-support/types.ts +25 -188
  221. package/src/pagination/ItemIndex.ts +4 -12
  222. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  223. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
  224. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  225. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
  226. package/src/pagination/filterCompiler.ts +11 -25
  227. package/src/pagination/paginators/BasePaginator.ts +422 -976
  228. package/src/pagination/paginators/ChannelPaginator.ts +130 -190
  229. package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
  230. package/src/pagination/paginators/MessagePaginator.ts +135 -175
  231. package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
  232. package/src/pagination/paginators/ReminderPaginator.ts +12 -15
  233. package/src/pagination/paginators/ThreadPaginator.ts +16 -26
  234. package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
  235. package/src/pagination/paginators/stateThrottling.ts +5 -10
  236. package/src/pagination/sortCompiler.ts +23 -50
  237. package/src/pagination/utility.normalization.ts +8 -30
  238. package/src/pagination/utility.search.ts +4 -11
  239. package/src/poll.ts +19 -19
  240. package/src/poll_manager.ts +16 -20
  241. package/src/poll_optimistic_votes.ts +17 -22
  242. package/src/reminders/Reminder.ts +5 -6
  243. package/src/reminders/ReminderManager.ts +9 -34
  244. package/src/reminders/ReminderTimer.ts +1 -2
  245. package/src/search/BaseSearchSource.ts +14 -29
  246. package/src/search/ChannelSearchSource.ts +8 -8
  247. package/src/search/MessageSearchSource.ts +19 -25
  248. package/src/search/SearchController.ts +18 -24
  249. package/src/search/types.ts +6 -10
  250. package/src/segment.ts +1 -1
  251. package/src/signing.ts +23 -3
  252. package/src/thread.ts +72 -173
  253. package/src/thread_manager.ts +59 -76
  254. package/src/token_manager.ts +11 -21
  255. package/src/types.ts +78 -126
  256. package/src/types.utility.ts +3 -3
  257. package/src/upload-utils.ts +5 -10
  258. package/src/uploadManager.ts +22 -54
  259. package/src/utils/FixedSizeQueueCache.ts +13 -21
  260. package/src/utils/WithSubscriptions.ts +5 -15
  261. package/src/utils/concurrency.ts +16 -55
  262. package/src/utils/mergeWith/mergeWith.ts +10 -13
  263. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  264. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  265. package/src/utils/objectPath.ts +6 -41
  266. package/src/utils/retryable.ts +10 -14
  267. package/src/utils/throttling/throttle.ts +9 -25
  268. package/src/utils/time.ts +26 -66
  269. package/src/utils.ts +72 -128
package/src/thread.ts CHANGED
@@ -49,10 +49,7 @@ const getCursorFromReplies = (
49
49
  };
50
50
 
51
51
  export type ThreadState = {
52
- /**
53
- * Determines if the thread is currently opened and on-screen. When the thread is active,
54
- * all new messages are immediately marked as read.
55
- */
52
+ /** Whether the thread is open and on-screen. While active, new messages are marked read. */
56
53
  active: boolean;
57
54
  channel: Channel;
58
55
  /** Unix nanoseconds, as the API sends it. */
@@ -62,10 +59,7 @@ export type ThreadState = {
62
59
  deletedAt: TimestampNS | null;
63
60
  isLoading: boolean;
64
61
  isStateStale: boolean;
65
- /**
66
- * Thread is identified by and has a one-to-one relation with its parent message.
67
- * We use parent message id as a thread id.
68
- */
62
+ /** A thread maps one-to-one to its parent message, whose ID is the thread ID. */
69
63
  parentMessage: LocalMessage;
70
64
  participants: ThreadStateResponse['thread_participants'];
71
65
  read: ThreadReadState;
@@ -107,15 +101,10 @@ export type ThreadConfig = {
107
101
  };
108
102
  };
109
103
 
110
- /**
111
- * Empty because every field of `ThreadConfig` is optional — a thread's own configuration is one handler
112
- * wide. Declared and frozen anyway, so the entity carries the same defaults layer as every other
113
- * configurable class rather than a special case.
114
- */
104
+ /** Empty: every field of `ThreadConfig` is optional. */
115
105
  export const DEFAULT_THREAD_CONFIG: ThreadConfig = deepFreezeConfig({});
116
106
 
117
107
  export class Thread extends WithSubscriptions {
118
- /** The shared configuration machinery — see {@link ConfigController}. */
119
108
  private readonly configController = new ConfigController<ThreadConfig>({
120
109
  defaults: DEFAULT_THREAD_CONFIG,
121
110
  });
@@ -127,7 +116,6 @@ export class Thread extends WithSubscriptions {
127
116
 
128
117
  private client: StreamChat;
129
118
  private failedRepliesMap: Map<string, LocalMessage> = new Map();
130
- /** How many activations (`activate()` calls) have not been released yet. */
131
119
  private _activeRefCount = 0;
132
120
 
133
121
  constructor({
@@ -162,14 +150,11 @@ export class Thread extends WithSubscriptions {
162
150
  });
163
151
 
164
152
  this.state = new StateStore<ThreadState>({
165
- // local only
166
153
  active: false,
167
154
  isLoading: false,
168
155
  isStateStale: false,
169
- // 99.9% should never change
170
156
  channel: threadChannel,
171
157
  createdAt: threadData.created_at,
172
- // rest
173
158
  deletedAt: threadData.deleted_at ?? null,
174
159
  parentMessage: formatMessage(threadData.parent_message),
175
160
  participants: threadData.thread_participants,
@@ -178,11 +163,8 @@ export class Thread extends WithSubscriptions {
178
163
  ? getPlaceholderReadResponse(client.userId)
179
164
  : threadData.read,
180
165
  ),
181
- // Use the parent message's reply_count, not the top-level threadData.reply_count. The
182
- // thread endpoints (getThread/queryThreads) return a top level reply_count that EXCLUDES
183
- // soft-deleted replies, while parent_message.reply_count (and the channel's own copy)
184
- // INCLUDE them so the top level value renders fewer replies than the channel badge shows.
185
- // parent_message.reply_count is the authoritative, channel consistent count.
166
+ // From the parent message: the top-level `threadData.reply_count` excludes soft-deleted
167
+ // replies, the parent's (like the channel's) includes them.
186
168
  replyCount: threadData.parent_message.reply_count ?? 0,
187
169
  updatedAt: threadData.updated_at ?? null,
188
170
  title: threadData.title,
@@ -212,11 +194,9 @@ export class Thread extends WithSubscriptions {
212
194
  custom: {},
213
195
  deletedAt: formattedParentMessage.deleted_at ?? null,
214
196
  isLoading: false,
215
- // Only the parent message is known, so the thread loads its data once when opened if it may
216
- // have any: when the parent has replies, and when its channel isn't watched, as the parent's
217
- // `reply_count` then misses the replies sent since the channel was loaded. A parent without
218
- // replies in a watched channel has nothing on the server yet (`getThread` would answer 404):
219
- // its first reply arrives as an event.
197
+ // Loads its data once when opened. A parent without replies in a watched channel has nothing
198
+ // on the server yet (`getThread` would answer 404); in an unwatched channel `reply_count` may
199
+ // miss newer replies, so it loads.
220
200
  isStateStale:
221
201
  replyCount > 0 || channel.watchStatus !== ChannelWatchStatus.Watching,
222
202
  parentMessage: formattedParentMessage,
@@ -232,11 +212,9 @@ export class Thread extends WithSubscriptions {
232
212
 
233
213
  this.client = client;
234
214
 
235
- // Read the declarative configuration before the sub-objects exist, so it can go in as constructor
236
- // options — the reply paginator's `unreadReferencePolicy` and initial cursor are read once.
215
+ // Read up front: the reply paginator takes `unreadReferencePolicy` as a constructor argument.
237
216
  const declarativeConfig = client.config.getConfig('thread') ?? undefined;
238
- // Thread replies are backed by a MessagePaginator too, so the general key applies here as well;
239
- // the per-parent slice overrides it (thread replies default to a smaller page than a channel).
217
+ // The general `messagePaginator` key applies to replies; the thread's own slice overrides it.
240
218
  const messagePaginatorConfig = mergeDeclarativePaginatorConfig(
241
219
  client.config.getConfig('messagePaginator') ?? undefined,
242
220
  declarativeConfig?.messagePaginator,
@@ -248,24 +226,19 @@ export class Thread extends WithSubscriptions {
248
226
  parentMessageId: this.id,
249
227
  requestSort: DEFAULT_SORT,
250
228
  itemOrder: DEFAULT_ITEM_ORDER,
251
- // Split as in `Channel`: the policy is a constructor argument, not paginator configuration.
229
+ // A constructor argument, not paginator configuration.
252
230
  unreadReferencePolicy: messagePaginatorConfig?.unreadReferencePolicy,
253
231
  paginatorOptions: {
254
232
  declarativeConfig: toDeclarativePaginatorConfig(messagePaginatorConfig),
255
233
  },
256
234
  },
257
- // Thread replies default to a smaller page than a channel list. Supplied by the SDK, not by the
258
- // integrator, so it sits at stage 1 — `client.config.set({ messagePaginator: { pageSize } })`
259
- // overrides it, which would not be true of a construction argument.
235
+ // SDK default page size. Overridable through `client.config.set`
236
+ // (`messagePaginator.pageSize`).
260
237
  { pageSize: DEFAULT_PAGE_LIMIT },
261
238
  );
262
239
 
263
- // Seed the reply paginator from the thread's `latest_replies` so a thread we already hold
264
- // data for (queried via the ThreadManager or hydrated from a ThreadResponse) renders its
265
- // first reply page instantly, without a network fetch on open. `latest_replies` is the most
266
- // recent window of replies, so it reaches the head (nothing newer to load); it reaches the
267
- // tail only when it already contains every reply. Threads built from a bare parent message
268
- // carry no replies to seed and fall back to a paginator fetch on first open.
240
+ // Seeds the first reply page without a fetch. `latest_replies` is the newest window: it reaches
241
+ // the head, and the tail only if it holds every reply.
269
242
  if (threadData?.latest_replies?.length) {
270
243
  const replies = threadData.latest_replies.map(formatMessage);
271
244
  const isLastPage = replies.length === (threadData.reply_count ?? 0);
@@ -277,9 +250,7 @@ export class Thread extends WithSubscriptions {
277
250
  });
278
251
  }
279
252
 
280
- // Seed the reply paginator's lastMessageAt floor from the thread's server-provided
281
- // `last_message_at` (analogous to the channel seed in Channel._initializeState), so a thread whose
282
- // newest reply is not among `latest_replies` still reports the correct latest-activity timestamp.
253
+ // Floor for `lastMessageAt`, for when the newest reply is not among `latest_replies`.
283
254
  this.messagePaginator.seedLastMessageAt(threadData?.last_message_at);
284
255
 
285
256
  this.messageComposer = new MessageComposer({
@@ -290,24 +261,17 @@ export class Thread extends WithSubscriptions {
290
261
 
291
262
  this.messageOperations = createMessageOperations(this);
292
263
 
293
- // Share one derivation path with `config.reset()`. Idempotent — the paginator was already
294
- // configured through its constructor above; this re-applies the mutable half the way a reset does.
264
+ // Same derivation path as `config.reset()`. Idempotent: re-applies what the constructors set.
295
265
  this.initializeConfig(declarativeConfig);
296
266
  }
297
267
 
298
268
  /**
299
- * Derives this thread's configuration — and its reply paginator's — from the declarative slice.
300
- *
301
- * Called by the constructor and by `client.config.reset()`. The thread owns only its own
302
- * `requestHandlers`; the paginator derives its own configuration.
269
+ * Derives this thread's configuration, and its reply paginator's, from the declarative slice.
270
+ * Called by the constructor and by `client.config.reset()`.
303
271
  */
304
272
  initializeConfig(declarativeConfig?: ThreadDeclarativeConfig): void {
305
- // Only the thread's own slice goes in. The paginator and the operations keys are handed to those
306
- // objects below, so putting them here too would publish them on `thread.config` as well.
307
- //
308
- // Replaces rather than merges: a handler dropped from the declarative tree must disappear. The
309
- // controller skips a write that changes nothing, which matters because `alsoWatch` re-runs this for
310
- // any of three keys and `useThreadRequestHandlers` subscribes to the store.
273
+ // Only the thread's own slice: the paginator and operations keys go to those objects below.
274
+ // Replaces rather than merges, so a handler dropped from the declarative tree disappears.
311
275
  this.configController.initialize({
312
276
  requestHandlers: declarativeConfig?.requestHandlers,
313
277
  });
@@ -321,8 +285,7 @@ export class Thread extends WithSubscriptions {
321
285
  ),
322
286
  );
323
287
 
324
- // A thread sends messages too, so it owns a `MessageOperations` of its own and takes the same shared
325
- // key the channel does, with its own per-parent override.
288
+ // Takes the shared `messageOperations` key like the channel does, with its own override.
326
289
  this.messageOperations.initializeConfig(
327
290
  mergeDeclarativeMessageOperationsConfig(
328
291
  this.client.config.getConfig('messageOperations') ?? undefined,
@@ -331,23 +294,19 @@ export class Thread extends WithSubscriptions {
331
294
  );
332
295
  }
333
296
 
334
- /**
335
- * Resolved configuration as a store, so consumers can react to it — the shape every configurable class
336
- * exposes.
337
- */
338
297
  get configState(): StateStore<ThreadConfig> {
339
298
  return this.configController.state;
340
299
  }
341
300
 
342
- /**
343
- * This thread's resolved configuration. `Readonly` because the value is the store's live object —
344
- * assigning to a field of it would change state without notifying anyone. Use {@link updateConfig}.
345
- */
346
301
  get config(): Readonly<ThreadConfig> {
347
302
  return this.configController.value;
348
303
  }
349
304
 
350
- /** Merges a partial configuration into the resolved config and notifies subscribers. */
305
+ /**
306
+ * Merges a partial configuration into the resolved config.
307
+ *
308
+ * @param config - The fields to change.
309
+ */
351
310
  updateConfig(config: Partial<ThreadConfig>): void {
352
311
  this.configController.patch(config);
353
312
  }
@@ -365,17 +324,12 @@ export class Thread extends WithSubscriptions {
365
324
  }
366
325
 
367
326
  /**
368
- * Declares that a consumer is displaying this thread, and returns the function that ends it, as
369
- * `channel.activate()` does. Refcounted, as one `Thread` can be held by several consumers at once,
370
- * so it stays active until the last one releases. Each call gets its own release, and calling a
371
- * release again does nothing, so a consumer can't end another one's activation.
327
+ * Declares that a consumer is displaying this thread and returns the function that ends it (as
328
+ * `channel.activate()`). Refcounted: the thread stays active until the last release, and each
329
+ * release is idempotent. `active` selects the threads reloaded on reconnect, so release it.
372
330
  *
373
- * `active` is also what {@link ConnectionRecoveryManager} filters on to decide which threads to
374
- * reload on reconnect, so an activation that is never released costs more than a missed auto-read.
375
- *
376
- * The first activation also keeps the thread in `client.threads` for the rest of the session:
377
- * it stays subscribed and resolvable through `client.threads.get(id)` after it is released,
378
- * whether or not the thread list holds it. Reopening it therefore needs no fetch unless it went stale.
331
+ * The first activation keeps the thread in `client.threads` for the session, subscribed and
332
+ * resolvable through `client.threads.get(id)` after release.
379
333
  */
380
334
  public activate = (): (() => void) => {
381
335
  this._activeRefCount += 1;
@@ -396,19 +350,10 @@ export class Thread extends WithSubscriptions {
396
350
  };
397
351
 
398
352
  /**
399
- * Re-queries this thread's replies, sized to the loaded window, and reconciles them in place — the
400
- * thread analogue of {@link Channel.reload}, and what connection recovery calls for every active
401
- * thread.
402
- *
403
- * Preserves failed (unsent) replies. They are read out of the reply paginator rather than out of
404
- * `failedRepliesMap`, because that map is only written by `upsertReplyLocally`, whose callers are
405
- * this thread's own subscriptions and the offline-DB path resolved through `client.threads.get` —
406
- * neither of which covers a thread that was never activated or listed. Reading the paginator
407
- * is true for registered and unregistered threads alike. An overlap merge keeps them anyway (the
408
- * reconcile's provenance guard never prunes a non-server message); only a disjoint rebuild can drop
409
- * them, so any that actually fell out are re-ingested below.
410
- *
411
- * Rethrows, except for a not-found answer on a thread that never had replies (see the catch).
353
+ * Re-queries the replies, sized to the loaded window, and reconciles them in place (the thread
354
+ * analogue of {@link Channel.reload}; recovery calls it for active threads). Failed replies are
355
+ * kept, read from the reply paginator since `failedRepliesMap` misses threads never activated or
356
+ * listed. Rethrows, except for a not-found answer on a thread that never had replies.
412
357
  */
413
358
  public reload = async () => {
414
359
  if (this.state.getLatestValue().isLoading) {
@@ -424,10 +369,13 @@ export class Thread extends WithSubscriptions {
424
369
  Math.max(loadedReplyCount, this.messagePaginator.pageSize ?? 0) || undefined;
425
370
  const reconcileCandidateIds = new Set(loadedReplies.map((reply) => reply.id));
426
371
  const failedBefore = loadedReplies.filter((reply) => reply.status === 'failed');
427
- const thread = await this.client.getThreadAndHydrate(this.id, {
428
- watch: true,
429
- reply_limit: requestedReplyLimit,
430
- });
372
+ const thread = await this.client.getThreadAndHydrate(
373
+ { message_id: this.id },
374
+ {
375
+ watch: true,
376
+ reply_limit: requestedReplyLimit,
377
+ },
378
+ );
431
379
  this.hydrateState(thread, {
432
380
  reconcile: {
433
381
  requestedLimit: requestedReplyLimit,
@@ -436,9 +384,8 @@ export class Thread extends WithSubscriptions {
436
384
  });
437
385
 
438
386
  if (failedBefore.length) {
439
- // Membership is checked against the visible window, NOT `getItem`: that reads the item
440
- // index, which can still hold a message the rebuild dropped from the loaded window — so an
441
- // index-based guard skips the re-ingest on exactly the path that needs it.
387
+ // Checks the visible window, not `getItem`: the item index can still hold a message the
388
+ // rebuild dropped from the loaded window.
442
389
  const visible = new Set((this.messagePaginator.items ?? []).map((r) => r.id));
443
390
  this.messagePaginator.batch(
444
391
  () => {
@@ -454,9 +401,7 @@ export class Thread extends WithSubscriptions {
454
401
  isDoesNotExistError(error as Error) ||
455
402
  (error as { status?: number })?.status === 404;
456
403
  const neverExisted = notFound && this.state.getLatestValue().replyCount === 0;
457
- // Do not throw an error if we haven't created the thread yet, the tiebreaker
458
- // being whether the parent message has any replies or not. A thread with all hard
459
- // deleted replies will simply not throw.
404
+ // Not found while the parent has no replies: the thread was never created, not an error.
460
405
  if (neverExisted) return;
461
406
 
462
407
  throw error;
@@ -470,7 +415,6 @@ export class Thread extends WithSubscriptions {
470
415
  options?: { reconcile?: MergeNewestPageOptions },
471
416
  ) => {
472
417
  if (thread === this) {
473
- // skip if the instances are the same
474
418
  return;
475
419
  }
476
420
 
@@ -492,9 +436,7 @@ export class Thread extends WithSubscriptions {
492
436
  updatedAt,
493
437
  } = thread.state.getLatestValue();
494
438
 
495
- // Preserve pending (failed) replies so they survive the hydrate. The messagePaginator is now
496
- // the sole reply source, so we merge the incoming newest page into it and re-ingest the
497
- // pending replies (mirrors the previous state.replies concat behavior).
439
+ // Failed replies survive the hydrate: they are re-ingested after the incoming page is merged.
498
440
  const pendingReplies = Array.from(this.failedRepliesMap.values());
499
441
 
500
442
  this.state.partialNext({
@@ -518,11 +460,8 @@ export class Thread extends WithSubscriptions {
518
460
 
519
461
  if (!options?.reconcile) this.messagePaginator.clearStateAndCache();
520
462
  if (typeof this.messagePaginator.items === 'undefined') {
521
- // Nothing loaded yet — the common case for a thread opened from a message, whose paginator
522
- // has never held a window. `mergeNewestPage` deliberately no-ops there (it merges into an
523
- // anchored head and leaves seeding to the query path), so hydrating through it would drop the
524
- // replies this request just fetched and leave the panel empty until something else queried
525
- // them. Seed instead, exactly as the constructor does for a thread response's `latest_replies`.
463
+ // Nothing loaded yet (e.g. a thread opened from a message): `mergeNewestPage` no-ops without
464
+ // an anchored head and would drop the fetched replies, so seed as the constructor does.
526
465
  const isLastPage = incomingReplies.length === replyCount;
527
466
  this.messagePaginator.setItems({
528
467
  valueOrFactory: incomingReplies,
@@ -534,14 +473,12 @@ export class Thread extends WithSubscriptions {
534
473
  this.messagePaginator.mergeNewestPage(incomingReplies, options?.reconcile);
535
474
  }
536
475
  pendingReplies.forEach((reply) => this.messagePaginator.ingestItem(reply));
537
- // Carry the re-queried thread's last-activity floor so lastMessageAt stays fresh even when the
538
- // merged page does not include the newest reply. Monotonic, so an older value is a no-op.
476
+ // Keeps `lastMessageAt` fresh when the merged page lacks the newest reply. Monotonic.
539
477
  this.messagePaginator.seedLastMessageAt(thread.messagePaginator.lastMessageAt);
540
478
  };
541
479
 
542
480
  public registerSubscriptions = () => {
543
481
  if (this.hasSubscriptions) {
544
- // Thread is already listening for events and changes
545
482
  return;
546
483
  }
547
484
 
@@ -553,27 +490,11 @@ export class Thread extends WithSubscriptions {
553
490
  };
554
491
 
555
492
  /**
556
- * Subscribes this thread to the `'thread'` configuration key. Registered through
557
- * `WithSubscriptions`, so `unregisterSubscriptions()` runs the setup function's teardown.
558
- *
559
- * **This is where `Thread` differs from `Channel`,** which subscribes from its constructor. Everything
560
- * below follows from that, and applies to a thread that never calls `registerSubscriptions()`:
561
- *
562
- * - no *setup function* runs for it — matching how `MessageComposer` already behaves;
563
- * - it sees the declarative slice **as it stood when the thread was constructed**, because the
564
- * constructor applies it directly, but no *later* `client.config.set({ thread: … })` or
565
- * `set({ messagePaginator: … })` reaches it;
566
- * - it is absent from the registry's `liveInstances`, so `client.config.reset()` skips it, and
567
- * `hasLiveInstances('thread')` does not count it when deciding whether to warn about a
568
- * construction-only path registered too late.
569
- *
570
- * So read "declarative configuration is unaffected" as *at construction only*. A thread registered
571
- * with a `ThreadManager` that has itself registered is covered — the manager calls
572
- * `registerSubscriptions()` on every thread the list holds or that is active — so the common path
573
- * is fine. A thread that is neither, or held by an unregistered manager, is not.
574
- *
575
- * The alternative — applying the setup function at construction — would break the teardown symmetry
576
- * `WithSubscriptions` provides, which is why the asymmetry stands.
493
+ * Subscribes to the `'thread'` configuration key. Unlike `Channel`, which subscribes in its
494
+ * constructor, a thread that never registers sees the declarative slice only as of construction:
495
+ * no setup function runs, later `client.config.set` calls miss it and `client.config.reset()`
496
+ * skips it. `ThreadManager` registers the threads it holds (listed, `ensure()`d or active) while
497
+ * its own subscriptions are registered.
577
498
  */
578
499
  private subscribeThreadSetupStateChange = () =>
579
500
  applyInstanceConfiguration({
@@ -584,8 +505,8 @@ export class Thread extends WithSubscriptions {
584
505
  // Read fresh: by the time reset calls this, the declarative store has been cleared.
585
506
  reinitializeConfig: () =>
586
507
  this.initializeConfig(this.client.config.getConfig('thread') ?? undefined),
587
- // The reply paginator also derives from the shared `messagePaginator` key — run the full cycle
588
- // on a change there, so the setup function's overrides survive.
508
+ // Also rerun on the shared keys the reply paginator and operations derive from, so the setup
509
+ // function's overrides survive.
589
510
  alsoWatch: ['messagePaginator', 'messageOperations'],
590
511
  });
591
512
 
@@ -676,8 +597,6 @@ export class Thread extends WithSubscriptions {
676
597
 
677
598
  this.upsertReplyLocally({
678
599
  message: event.message,
679
- // MessageRequest from current user could have been added optimistically,
680
- // so the actual timestamp might differ in the event
681
600
  timestampChanged: isOwnMessage,
682
601
  });
683
602
 
@@ -694,8 +613,7 @@ export class Thread extends WithSubscriptions {
694
613
  let nextUserRead: ThreadUserReadState = userRead;
695
614
 
696
615
  if (userId === event.user?.id) {
697
- // The user who just sent a message to the thread has no unread messages
698
- // in that thread
616
+ // The sender has no unread messages.
699
617
  nextUserRead = {
700
618
  ...nextUserRead,
701
619
  lastReadAt: timestampOr(event.created_at, nowNs()),
@@ -705,7 +623,6 @@ export class Thread extends WithSubscriptions {
705
623
  } else if (active && userId === this.client.userId) {
706
624
  // Do not increment unread count for the current user in an active thread
707
625
  } else {
708
- // Increment unread count for all users except the author of the new message
709
626
  nextUserRead = {
710
627
  ...nextUserRead,
711
628
  unreadMessageCount: userRead.unreadMessageCount + 1,
@@ -745,17 +662,14 @@ export class Thread extends WithSubscriptions {
745
662
  if (!event.message) return;
746
663
  const formattedMessage = formatMessage(event.message);
747
664
 
748
- // Deleted message is a reply of this thread
749
665
  if (event.message.parent_id === this.id) {
750
666
  if (event.hard_delete) {
751
667
  this.deleteReplyLocally({ message: event.message });
752
668
  } else {
753
- // Handle soft delete (updates deleted_at timestamp)
754
669
  this.upsertReplyLocally({ message: event.message });
755
670
  }
756
671
  }
757
672
 
758
- // Deleted message is parent message of this thread
759
673
  if (event.message.id === this.id) {
760
674
  this.updateParentMessageLocally({ message: event.message });
761
675
  }
@@ -765,10 +679,8 @@ export class Thread extends WithSubscriptions {
765
679
 
766
680
  public handleMessageUpdated = (event: PipelineEvent) => {
767
681
  if (!event.message) return;
768
- // A `message.updated` WS event carries `own_reactions: []`; upserting it verbatim would
769
- // wipe the current user's reactions on an edit. Preserve them off the copy we already hold
770
- // — the reply paginator for a reply, `state.parentMessage` for the parent (the parent is
771
- // not held in any paginator, so it needs the same treatment directly).
682
+ // A `message.updated` event carries `own_reactions: []`, which would wipe the current user's
683
+ // reactions: keep them from the held copy (the reply paginator, or `state.parentMessage`).
772
684
  const message =
773
685
  event.message.parent_id === this.id
774
686
  ? {
@@ -795,9 +707,7 @@ export class Thread extends WithSubscriptions {
795
707
  this.messagePaginator.reflectQuotedMessageUpdate(formatMessage(message));
796
708
  };
797
709
 
798
- // Apply a user ban / deletion to this thread's own reply list. Previously
799
- // channel.state.deleteUserMessages marked banned-user replies deleted in the (now removed)
800
- // channel.state.threads shadow; the reply paginator is the thread's source of truth now.
710
+ // Applies a user ban or deletion to this thread's replies.
801
711
  public handleUserMessagesDeleted = (event: PipelineEvent) => {
802
712
  if (!event.user) return;
803
713
  // user.deleted carries the deletion time on the user; user.messages.deleted on the event.
@@ -810,12 +720,9 @@ export class Thread extends WithSubscriptions {
810
720
  });
811
721
  };
812
722
 
813
- // The parent message lives in the client-global message store (one canonical POJO per id);
814
- // `state.parentMessage` and the fields derived from it are a projection of that copy. Every update
815
- // to the parent — optimistic reaction, WS reaction/edit/delete, reply-count bump — writes the
816
- // store, which reflects it here through this single subscription (one per thread, not one per
817
- // message). Seeds the store on first subscribe when no other collection holds the parent yet
818
- // (e.g. a thread opened from a notification, its parent not in the channel window).
723
+ // `state.parentMessage` and its derived fields project the parent in the client-global message
724
+ // store, so every update to the parent reaches them through this one subscription. Seeds the
725
+ // store when no other collection holds the parent yet (e.g. a thread opened from a notification).
819
726
  private subscribeParentMessageFromStore = () => {
820
727
  const store = this.client.messageStore;
821
728
  const parent = this.state.getLatestValue().parentMessage;
@@ -837,11 +744,9 @@ export class Thread extends WithSubscriptions {
837
744
 
838
745
  public unregisterSubscriptions = () => {
839
746
  const symbol = super.unregisterSubscriptions();
840
- // Release the reply paginator's hold on the shared message store. The parent subscription is
841
- // torn down by `super.unregisterSubscriptions()` (it was added as an unsubscribe function), but
842
- // the reply paginator's per-id links live in its item index, not in the subscription list — so a
843
- // removed thread would otherwise stay pinned by `messageStore.subscribers` and keep its replies
844
- // alive. `getThread` builds a fresh instance if this thread is re-opened, so this is a discard.
747
+ // Releases the reply paginator's per-ID links on the shared message store (they are not in the
748
+ // subscription list), which would otherwise pin a removed thread and its replies. `getThread`
749
+ // builds a fresh instance if the thread is re-opened.
845
750
  this.messagePaginator.dispose();
846
751
  this.state.partialNext({ isStateStale: true });
847
752
  return symbol;
@@ -849,8 +754,7 @@ export class Thread extends WithSubscriptions {
849
754
 
850
755
  // todo: can be removed with the next breaking change and use MessagePaginator only
851
756
  public deleteReplyLocally = ({ message }: { message: MessageResponse }) => {
852
- // The reply messagePaginator is the reply list source. removeItem is a no-op when the reply
853
- // isn't loaded, so it's safe to run unconditionally.
757
+ // A no-op when the reply is not loaded.
854
758
  this.messagePaginator.removeItem({ id: message.id });
855
759
  };
856
760
 
@@ -859,8 +763,7 @@ export class Thread extends WithSubscriptions {
859
763
  message,
860
764
  }: {
861
765
  message: MessageResponse | LocalMessage;
862
- // Accepted for backward compatibility but no longer used — the messagePaginator repositions
863
- // by created_at on ingest, so a changed timestamp is handled without an explicit flag.
766
+ // Unused: the reply paginator repositions by `created_at` on ingest.
864
767
  timestampChanged?: boolean;
865
768
  }) => {
866
769
  if (message.parent_id !== this.id) {
@@ -871,20 +774,18 @@ export class Thread extends WithSubscriptions {
871
774
 
872
775
  // todo: do we really need to keep the failedRepliesMap?
873
776
  if (formattedMessage.status === 'failed') {
874
- // store failed reply so that it's not lost when reloading or hydrating
777
+ // Kept so a failed reply survives a reload or hydrate.
875
778
  this.failedRepliesMap.set(formattedMessage.id, formattedMessage);
876
779
  } else if (this.failedRepliesMap.has(message.id)) {
877
780
  this.failedRepliesMap.delete(message.id);
878
781
  }
879
782
 
880
- // Already showing this exact snapshot because a holder sharing the store wrote it first and the
881
- // fanout reprojected us. Ingesting would re-emit an identical window for nothing.
783
+ // Already showing this snapshot (a holder sharing the store wrote it first): skip the ingest.
882
784
  // TODO: This can probably be generalized as a safeguard up in ingestItem or maybe even EntityStore
883
785
  // (so if a collection exists that holds this referential entity already, just use that or maybe
884
786
  // even skip ingestion sometimes when it makes sense). But leaving that for a separate change.
885
787
  if (this.messagePaginator.getItem(formattedMessage.id) === formattedMessage) return;
886
788
 
887
- // The reply messagePaginator is the reply list source.
888
789
  this.messagePaginator.ingestItem(formattedMessage);
889
790
  };
890
791
 
@@ -894,9 +795,7 @@ export class Thread extends WithSubscriptions {
894
795
  throw new Error('Message does not belong to this thread');
895
796
  }
896
797
 
897
- // The parent's content lives in the client-global message store; `state.parentMessage` (and the
898
- // fields derived from it) is a projection kept in sync by `subscribeParentMessageFromStore`.
899
- // Writing the store fans the change out to every collection holding this id and reflects it here.
798
+ // Written to the message store; `subscribeParentMessageFromStore` projects it into the state.
900
799
  if (this.client.messageStore.has(message.id)) {
901
800
  this.client.messageStore.upsert(formatMessage(message));
902
801
  }