@talkjs/core 1.1.0 → 1.2.0
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.
- package/README.md +10 -0
- package/dist/talkSession.cjs +1 -1
- package/dist/talkSession.d.ts +116 -3
- package/dist/talkSession.js +835 -666
- package/package.json +1 -1
package/dist/talkSession.d.ts
CHANGED
|
@@ -381,6 +381,19 @@ export declare interface ConversationRef {
|
|
|
381
381
|
* The snapshot is null if you are not a participant in the conversation (including when the conversation doesn't exist)
|
|
382
382
|
*/
|
|
383
383
|
subscribeMessages(onSnapshot?: (snapshot: MessageSnapshot[] | null, loadedAll: boolean) => void): MessageSubscription;
|
|
384
|
+
/**
|
|
385
|
+
* Subscribes to the participants in the conversation.
|
|
386
|
+
*
|
|
387
|
+
* @remarks
|
|
388
|
+
* Initially, you will be subscribed to the 10 participants who joined most recently, and any new participants.
|
|
389
|
+
* Call `loadMore` to load additional older participants.
|
|
390
|
+
*
|
|
391
|
+
* Whenever `Subscription.state.type` is "active" and a participant is created, edited, deleted, or you load more participants, `onSnapshot` will fire and `Subscription.state.latestSnapshot` will be updated.
|
|
392
|
+
* `loadedAll` is true when the snapshot contains all the participants in the conversation.
|
|
393
|
+
*
|
|
394
|
+
* The snapshot is null if you are not a participant in the conversation (including when the conversation doesn't exist)
|
|
395
|
+
*/
|
|
396
|
+
subscribeParticipants(onSnapshot?: (snapshot: ParticipantSnapshot[] | null, loadedAll: boolean) => void): ParticipantSubscription;
|
|
384
397
|
/**
|
|
385
398
|
* Subscribes to the conversation.
|
|
386
399
|
*
|
|
@@ -494,9 +507,25 @@ export declare interface ConversationSnapshot {
|
|
|
494
507
|
*/
|
|
495
508
|
unreadMessageCount: number;
|
|
496
509
|
/**
|
|
497
|
-
*
|
|
510
|
+
* The most recent date that the current user read the conversation.
|
|
511
|
+
*
|
|
512
|
+
* @remarks
|
|
513
|
+
* This value is updated whenever you read a message in a chat UI, open an email notification, or mark the conversation as read using an API like {@link ConversationRef.markAsRead}.
|
|
514
|
+
*
|
|
515
|
+
* Any messages sent after this timestamp are unread messages.
|
|
498
516
|
*/
|
|
499
517
|
readUntil: number;
|
|
518
|
+
/**
|
|
519
|
+
* Everyone in the conversation has read any messages sent on or before this date.
|
|
520
|
+
*
|
|
521
|
+
* @remarks
|
|
522
|
+
* This is the minimum of all the participants' `readUntil` values.
|
|
523
|
+
* Any messages sent on or before this timestamp should show a "read" indicator in the UI.
|
|
524
|
+
*
|
|
525
|
+
* This value will rarely change in very large conversations.
|
|
526
|
+
* If just one person stops checking their messages, `everyoneReadUntil` will never update.
|
|
527
|
+
*/
|
|
528
|
+
everyoneReadUntil: number;
|
|
500
529
|
/**
|
|
501
530
|
* Whether the conversation should be considered unread.
|
|
502
531
|
*
|
|
@@ -1229,7 +1258,7 @@ export declare interface MessageSnapshot {
|
|
|
1229
1258
|
* Get a MessageSubscription by calling {@link ConversationRef.subscribeMessages}
|
|
1230
1259
|
*
|
|
1231
1260
|
* The subscription is 'windowed'. It includes all messages since a certain point in time.
|
|
1232
|
-
* By default, you subscribe to the 30 most recent messages, and any new messages are sent after you subscribe.
|
|
1261
|
+
* By default, you subscribe to the 30 most recent messages, and any new messages that are sent after you subscribe.
|
|
1233
1262
|
*
|
|
1234
1263
|
* You can expand this window by calling {@link MessageSubscription.loadMore}, which extends the window further into the past.
|
|
1235
1264
|
*
|
|
@@ -1275,7 +1304,7 @@ export declare interface MessageSubscription {
|
|
|
1275
1304
|
* @remarks
|
|
1276
1305
|
* Calling `loadMore` multiple times in parallel will still only load one page of messages.
|
|
1277
1306
|
*
|
|
1278
|
-
* @param count - The number of additional messages to load. Must be between 1 and 100
|
|
1307
|
+
* @param count - The number of additional messages to load. Must be between 1 and 100. Default 30.
|
|
1279
1308
|
* @returns A promise that resolves once the additional messages have loaded
|
|
1280
1309
|
*/
|
|
1281
1310
|
loadMore(count?: number): Promise<void>;
|
|
@@ -1288,6 +1317,24 @@ export declare interface MessageSubscription {
|
|
|
1288
1317
|
unsubscribe(): void;
|
|
1289
1318
|
}
|
|
1290
1319
|
|
|
1320
|
+
/**
|
|
1321
|
+
* The state of a participants subscription when it is actively listening for changes
|
|
1322
|
+
*
|
|
1323
|
+
* @public
|
|
1324
|
+
*/
|
|
1325
|
+
export declare interface ParticipantActiveState {
|
|
1326
|
+
type: "active";
|
|
1327
|
+
/**
|
|
1328
|
+
* The most recently received snapshot for the participants, or `null` if you are not a participant in that conversation.
|
|
1329
|
+
*/
|
|
1330
|
+
latestSnapshot: ParticipantSnapshot[] | null;
|
|
1331
|
+
/**
|
|
1332
|
+
* True if `latestSnapshot` contains all participants in the conversation.
|
|
1333
|
+
* Use {@link ParticipantSubscription.loadMore} to load more.
|
|
1334
|
+
*/
|
|
1335
|
+
loadedAll: boolean;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1291
1338
|
/**
|
|
1292
1339
|
* References a given user's participation in a conversation.
|
|
1293
1340
|
*
|
|
@@ -1397,6 +1444,72 @@ export declare interface ParticipantSnapshot {
|
|
|
1397
1444
|
joinedAt: number;
|
|
1398
1445
|
}
|
|
1399
1446
|
|
|
1447
|
+
/**
|
|
1448
|
+
* A subscription to the participants in a specific conversation.
|
|
1449
|
+
*
|
|
1450
|
+
* @remarks
|
|
1451
|
+
* Get a ParticipantSubscription by calling {@link ConversationRef.subscribeParticipants}
|
|
1452
|
+
*
|
|
1453
|
+
* The subscription is 'windowed'. It includes everyone who joined since a certain point in time.
|
|
1454
|
+
* By default, you subscribe to the 10 most recent participants, and any participants who joined after you subscribe.
|
|
1455
|
+
*
|
|
1456
|
+
* You can expand this window by calling {@link ParticipantSubscription.loadMore}, which extends the window further into the past.
|
|
1457
|
+
*
|
|
1458
|
+
* @public
|
|
1459
|
+
*/
|
|
1460
|
+
export declare interface ParticipantSubscription {
|
|
1461
|
+
/**
|
|
1462
|
+
* The current state of the subscription
|
|
1463
|
+
*
|
|
1464
|
+
* @remarks
|
|
1465
|
+
* An object with the following fields:
|
|
1466
|
+
*
|
|
1467
|
+
* `type` is one of "pending", "active", "unsubscribed", or "error".
|
|
1468
|
+
*
|
|
1469
|
+
* When `type` is "active", includes `latestSnapshot` and `loadedAll`.
|
|
1470
|
+
*
|
|
1471
|
+
* - `latestSnapshot: ParticipantSnapshot[] | null` the current state of the participants in the window, or null if you're not a participant in the conversation
|
|
1472
|
+
*
|
|
1473
|
+
* - `loadedAll: boolean` true when `latestSnapshot` contains all the participants in the conversation
|
|
1474
|
+
*
|
|
1475
|
+
* When `type` is "error", includes the `error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
|
|
1476
|
+
*/
|
|
1477
|
+
state: PendingState | ParticipantActiveState | UnsubscribedState | ErrorState;
|
|
1478
|
+
/**
|
|
1479
|
+
* Resolves when the subscription starts receiving updates from the server.
|
|
1480
|
+
*
|
|
1481
|
+
* @remarks
|
|
1482
|
+
* Wait for this promise if you want to perform some action as soon as the subscription is active.
|
|
1483
|
+
*
|
|
1484
|
+
* The promise rejects if the subscription is terminated before it connects.
|
|
1485
|
+
*/
|
|
1486
|
+
connected: Promise<ParticipantActiveState>;
|
|
1487
|
+
/**
|
|
1488
|
+
* Resolves when the subscription permanently stops receiving updates from the server.
|
|
1489
|
+
*
|
|
1490
|
+
* @remarks
|
|
1491
|
+
* This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
|
|
1492
|
+
*/
|
|
1493
|
+
terminated: Promise<UnsubscribedState | ErrorState>;
|
|
1494
|
+
/**
|
|
1495
|
+
* Expand the window to include older participants
|
|
1496
|
+
*
|
|
1497
|
+
* @remarks
|
|
1498
|
+
* Calling `loadMore` multiple times in parallel will still only load one page of participants.
|
|
1499
|
+
*
|
|
1500
|
+
* @param count - The number of additional participants to load. Must be between 1 and 50. Default 10.
|
|
1501
|
+
* @returns A promise that resolves once the additional participants have loaded
|
|
1502
|
+
*/
|
|
1503
|
+
loadMore(count?: number): Promise<void>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Unsubscribe from this resource and stop receiving updates.
|
|
1506
|
+
*
|
|
1507
|
+
* @remarks
|
|
1508
|
+
* If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
|
|
1509
|
+
*/
|
|
1510
|
+
unsubscribe(): void;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1400
1513
|
/**
|
|
1401
1514
|
* The state of a subscription before it has connected to the server
|
|
1402
1515
|
*
|