@talkjs/core 1.7.0 → 1.8.1

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.
@@ -287,7 +287,9 @@ export declare interface ConversationListSubscription {
287
287
  * Expand the window to include older conversations
288
288
  *
289
289
  * @remarks
290
- * Calling `loadMore` multiple times in parallel will still only load one page of conversations.
290
+ * The `count` parameter is relative to the current number of loaded conversations.
291
+ * If you call `loadMore(5)` and then call `loadMore(10)` immediately afterwards (without awaiting the promise),
292
+ * then only 10 additional conversations will be loaded, not 15.
291
293
  *
292
294
  * Avoid calling `.loadMore` in a loop until you have loaded all conversations.
293
295
  * This is usually unnecessary: any time a conversation receives a message, it appears at the start of the list of conversations.
@@ -1595,7 +1597,9 @@ export declare interface MessageSubscription {
1595
1597
  * Expand the window to include older messages
1596
1598
  *
1597
1599
  * @remarks
1598
- * Calling `loadMore` multiple times in parallel will still only load one page of messages.
1600
+ * The `count` parameter is relative to the current number of loaded participants.
1601
+ * If you call `loadMore(5)` and then call `loadMore(10)` immediately afterwards (without awaiting the promise),
1602
+ * then only 10 additional participants will be loaded, not 15.
1599
1603
  *
1600
1604
  * Avoid calling `.loadMore` in a loop until you have loaded all messages.
1601
1605
  * If you do need to call loadMore in a loop, make sure you set an upper bound (e.g. 1000) on the number of messages, where the loop will exit.
@@ -1698,6 +1702,17 @@ export declare interface ParticipantRef {
1698
1702
  * @returns A promise that resolves when the operation completes. This promise will reject if client-side conversation syncing is disabled.
1699
1703
  */
1700
1704
  delete(): Promise<void>;
1705
+ /**
1706
+ * Subscribe to this participant's state.
1707
+ *
1708
+ * @remarks
1709
+ * While the subscription is active, `onSnapshot` will be called when the participant joins or leaves the conversation, or their attributes change, including attributes on their user.
1710
+ *
1711
+ * Remember to call `.unsubscribe` on the subscription once you are done with it.
1712
+ *
1713
+ * @returns A subscription to the participant
1714
+ */
1715
+ subscribe(onSnapshot?: (snapshot: ParticipantSnapshot | null) => void): SingleParticipantSubscription;
1701
1716
  }
1702
1717
 
1703
1718
  /**
@@ -1786,7 +1801,9 @@ export declare interface ParticipantSubscription {
1786
1801
  * Expand the window to include older participants
1787
1802
  *
1788
1803
  * @remarks
1789
- * Calling `loadMore` multiple times in parallel will still only load one page of participants.
1804
+ * The `count` parameter is relative to the current number of loaded messages.
1805
+ * If you call `loadMore(5)` and then call `loadMore(10)` immediately afterwards (without awaiting the promise),
1806
+ * then only 10 additional messages will be loaded, not 15.
1790
1807
  *
1791
1808
  * Avoid calling `.loadMore` in a loop until you have loaded all participants.
1792
1809
  * If you do need to call loadMore in a loop, make sure you set a small upper bound (e.g. 100) on the number of participants, where the loop will exit.
@@ -2279,6 +2296,64 @@ export declare interface SetUserParams {
2279
2296
  pushTokens?: Record<string, true | null> | null;
2280
2297
  }
2281
2298
 
2299
+ /**
2300
+ * The state of a participant subscription when it is actively listening for changes
2301
+ *
2302
+ * @public
2303
+ */
2304
+ export declare interface SingleParticipantActiveState {
2305
+ readonly type: "active";
2306
+ /**
2307
+ * The most recently received snapshot for the participant, or `null` if they are not a participant in that conversation.
2308
+ */
2309
+ readonly latestSnapshot: ParticipantSnapshot | null;
2310
+ }
2311
+
2312
+ /**
2313
+ * A subscription to a specific participant.
2314
+ *
2315
+ * @remarks
2316
+ * Get a SingleParticipantSubscription by calling {@link ParticipantRef.subscribe}
2317
+ *
2318
+ * Remember to `.unsubscribe` the subscription once you are done with it.
2319
+ *
2320
+ * @public
2321
+ */
2322
+ export declare interface SingleParticipantSubscription {
2323
+ /**
2324
+ * The current state of the subscription
2325
+ *
2326
+ * @remarks
2327
+ * An object with the following fields:
2328
+ *
2329
+ * `type` is one of "pending", "active", "unsubscribed", or "error".
2330
+ *
2331
+ * When `type` is "active", includes `latestSnapshot: ParticipantSnapshot | null`, the current state of the participant.
2332
+ * `latestSnapshot` is `null` when the user is not a participant or the conversation does not exist.
2333
+ *
2334
+ * When `type` is "error", includes the `error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
2335
+ */
2336
+ state: PendingState | SingleParticipantActiveState | UnsubscribedState | ErrorState;
2337
+ /**
2338
+ * Resolves when the subscription starts receiving updates from the server.
2339
+ */
2340
+ readonly connected: Promise<SingleParticipantActiveState>;
2341
+ /**
2342
+ * Resolves when the subscription permanently stops receiving updates from the server.
2343
+ *
2344
+ * @remarks
2345
+ * This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
2346
+ */
2347
+ readonly terminated: Promise<UnsubscribedState | ErrorState>;
2348
+ /**
2349
+ * Unsubscribe from this resource and stop receiving updates.
2350
+ *
2351
+ * @remarks
2352
+ * If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
2353
+ */
2354
+ unsubscribe(): void;
2355
+ }
2356
+
2282
2357
  export declare type Subscription = {
2283
2358
  unsubscribe: () => void;
2284
2359
  };
@@ -2439,6 +2514,8 @@ export declare interface TalkSession {
2439
2514
  * Creates a search for messages in all the current user's conversations.
2440
2515
  *
2441
2516
  * @remarks
2517
+ * The search feature is available on the Growth plan or higher. On the Basic plan, this method will return an error.
2518
+ *
2442
2519
  * Search is a two-step process. After calling `searchMessages`, call {@link MessageSearch.setQuery} to specify a search query and begin the search.
2443
2520
  *
2444
2521
  * As search can be quite slow, there are two different ways of using search:
@@ -2480,6 +2557,8 @@ export declare interface TalkSession {
2480
2557
  * Creates a search for all the current user's conversations.
2481
2558
  *
2482
2559
  * @remarks
2560
+ * The search feature is available on the Growth plan or higher. On the Basic plan, this method will return an error.
2561
+ *
2483
2562
  * Search is a two-step process. After calling `searchConversations`, call {@link ConversationSearch.setQuery} to specify a search query and begin the search.
2484
2563
  *
2485
2564
  * As search can be quite slow, there are two different ways of using search: