@talkjs/core 1.2.0 → 1.3.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 +5 -0
- package/dist/talkSession.cjs +1 -1
- package/dist/talkSession.d.ts +102 -0
- package/dist/talkSession.js +526 -354
- package/package.json +1 -1
package/dist/talkSession.d.ts
CHANGED
|
@@ -214,6 +214,92 @@ export declare interface ConversationActiveState {
|
|
|
214
214
|
latestSnapshot: ConversationSnapshot | null;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* The state of a conversation list subscription when it is actively listening for changes
|
|
219
|
+
*
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
export declare interface ConversationListActiveState {
|
|
223
|
+
type: "active";
|
|
224
|
+
/**
|
|
225
|
+
* The most recently received snapshot for the conversations
|
|
226
|
+
*/
|
|
227
|
+
latestSnapshot: ConversationSnapshot[];
|
|
228
|
+
/**
|
|
229
|
+
* True if `latestSnapshot` contains all conversations you are in.
|
|
230
|
+
* Use {@link ConversationListSubscription.loadMore} to load more.
|
|
231
|
+
*/
|
|
232
|
+
loadedAll: boolean;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* A subscription to your most recently active conversations.
|
|
237
|
+
*
|
|
238
|
+
* @remarks
|
|
239
|
+
* Get a ConversationListSubscription by calling {@link Session.subscribeConversations}.
|
|
240
|
+
*
|
|
241
|
+
* The subscription is 'windowed'. Initially, this window contains the 20 most recent conversations.
|
|
242
|
+
* Conversations are ordered by last activity. The last activity of a conversation is either `joinedAt` or `lastMessage.createdAt`, whichever is higher.
|
|
243
|
+
*
|
|
244
|
+
* The window will automatically expand to include any conversations you join, and any old conversations that receive new messages after subscribing.
|
|
245
|
+
*
|
|
246
|
+
* You can expand this window by calling {@link ConversationListSubscription.loadMore}, which extends the window further into the past.
|
|
247
|
+
*
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
export declare interface ConversationListSubscription {
|
|
251
|
+
/**
|
|
252
|
+
* The current state of the subscription
|
|
253
|
+
*
|
|
254
|
+
* @remarks
|
|
255
|
+
* An object with the following fields:
|
|
256
|
+
*
|
|
257
|
+
* `type` is one of "pending", "active", "unsubscribed", or "error".
|
|
258
|
+
*
|
|
259
|
+
* When `type` is "active", includes `latestSnapshot` and `loadedAll`.
|
|
260
|
+
*
|
|
261
|
+
* - `latestSnapshot: ConversationSnapshot[]` the current state of the conversations in the window
|
|
262
|
+
*
|
|
263
|
+
* - `loadedAll: boolean` true when `latestSnapshot` contains all the conversations you are in
|
|
264
|
+
*
|
|
265
|
+
* When `type` is "error", includes the `error` field. It is a JS `Error` object explaining what caused the subscription to be terminated.
|
|
266
|
+
*/
|
|
267
|
+
state: PendingState | ConversationListActiveState | UnsubscribedState | ErrorState;
|
|
268
|
+
/**
|
|
269
|
+
* Resolves when the subscription starts receiving updates from the server.
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* Wait for this promise if you want to perform some action as soon as the subscription is active.
|
|
273
|
+
*
|
|
274
|
+
* The promise rejects if the subscription is terminated before it connects.
|
|
275
|
+
*/
|
|
276
|
+
connected: Promise<ConversationListActiveState>;
|
|
277
|
+
/**
|
|
278
|
+
* Resolves when the subscription permanently stops receiving updates from the server.
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* This is either because you unsubscribed or because the subscription encountered an unrecoverable error.
|
|
282
|
+
*/
|
|
283
|
+
terminated: Promise<UnsubscribedState | ErrorState>;
|
|
284
|
+
/**
|
|
285
|
+
* Expand the window to include older conversations
|
|
286
|
+
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* Calling `loadMore` multiple times in parallel will still only load one page of conversations.
|
|
289
|
+
*
|
|
290
|
+
* @param count - The number of additional conversations to load. Must be between 1 and 30. Default 20.
|
|
291
|
+
* @returns A promise that resolves once the additional conversations have loaded
|
|
292
|
+
*/
|
|
293
|
+
loadMore(count?: number): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Unsubscribe from this resource and stop receiving updates.
|
|
296
|
+
*
|
|
297
|
+
* @remarks
|
|
298
|
+
* If the subscription is already in the "unsubscribed" or "error" state, this is a no-op.
|
|
299
|
+
*/
|
|
300
|
+
unsubscribe(): void;
|
|
301
|
+
}
|
|
302
|
+
|
|
217
303
|
/**
|
|
218
304
|
* References the conversation with a given conversation ID, from the perspective of the current user.
|
|
219
305
|
*
|
|
@@ -1937,6 +2023,22 @@ export declare interface TalkSession {
|
|
|
1937
2023
|
* @public
|
|
1938
2024
|
*/
|
|
1939
2025
|
conversation(id: string): ConversationRef;
|
|
2026
|
+
/**
|
|
2027
|
+
* Subscribes to your most recently active conversations.
|
|
2028
|
+
*
|
|
2029
|
+
* @remarks
|
|
2030
|
+
* The subscription is 'windowed'. Initially, this window contains the 20 most recent conversations.
|
|
2031
|
+
* Conversations are ordered by last activity. The last activity of a conversation is either `joinedAt` or `lastMessage.createdAt`, whichever is higher.
|
|
2032
|
+
*
|
|
2033
|
+
* If an older conversation receives a new message, or you are added to a conversation, it will appear at the start of the list.
|
|
2034
|
+
* Call `loadMore` to load additional older conversations.
|
|
2035
|
+
*
|
|
2036
|
+
* Whenever `Subscription.state.type` is "active" and something changes in your conversations, `onSnapshot` will fire and `Subscription.state.latestSnapshot` will be updated.
|
|
2037
|
+
* `loadedAll` is true when the snapshot contains all your conversations.
|
|
2038
|
+
*
|
|
2039
|
+
* If the current user does not exist yet, the snapshot will be an empty list.
|
|
2040
|
+
*/
|
|
2041
|
+
subscribeConversations(onSnapshot?: (snapshot: ConversationSnapshot[], loadedAll: boolean) => void): ConversationListSubscription;
|
|
1940
2042
|
/**
|
|
1941
2043
|
* Upload a generic file without any additional metadata.
|
|
1942
2044
|
*
|