stream-chat 10.0.0-rc.26 → 10.0.0-rc.27
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 +1 -1
- package/dist/cjs/index.browser.js +233 -29
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +233 -29
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +233 -29
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/ChannelManager.d.ts +2 -2
- package/dist/types/channel_state.d.ts +6 -5
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +12 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +4 -1
- package/dist/types/gen/chat/ChatApi.d.ts +16 -2
- package/dist/types/gen/models/index.d.ts +563 -103
- package/dist/types/gen/moderation/ModerationApi.d.ts +2 -1
- package/dist/types/pagination/paginators/BasePaginator.d.ts +2 -0
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +22 -2
- package/dist/types/utils/concurrency.d.ts +1 -1
- package/package.json +1 -1
- package/src/ChannelManager.ts +2 -2
- package/src/channel.ts +2 -11
- package/src/channel_state.ts +5 -3
- package/src/connection/wsConnection/StableWSConnection.ts +66 -3
- package/src/gen/chat/ChannelApi.ts +57 -0
- package/src/gen/chat/ChatApi.ts +56 -2
- package/src/gen/models/index.ts +620 -105
- package/src/gen/moderation/ModerationApi.ts +17 -0
- package/src/messageComposer/middleware/messageComposer/attachments.ts +19 -9
- package/src/pagination/paginators/BasePaginator.ts +9 -1
- package/src/pagination/paginators/ChannelPaginator.ts +100 -10
- package/src/poll_optimistic_votes.ts +6 -1
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ message.custom_property; // in the response object as well
|
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
> [!WARNING]
|
|
105
|
-
> Generics mechanism has been removed in version `9.0.0` in favour of the module augmentation, please see [the release guide](https://getstream.io/chat/docs/
|
|
105
|
+
> Generics mechanism has been removed in version `9.0.0` in favour of the module augmentation, please see [the release guide](https://getstream.io/chat/docs/javascript/upgrade-stream-chat-to-v9/) on how to migrate.
|
|
106
106
|
|
|
107
107
|
## 🔗 (Optional) Development Setup in Combination With Our SDKs
|
|
108
108
|
|
|
@@ -3407,22 +3407,24 @@ var localAttachmentToAttachment = (localAttachment) => {
|
|
|
3407
3407
|
const { localMetadata: _localMetadata, ...attachment } = localAttachment;
|
|
3408
3408
|
return attachment;
|
|
3409
3409
|
};
|
|
3410
|
+
var isSendable = (attachment) => isFinishedUpload(attachment) || !isLocalUploadAttachment(attachment);
|
|
3410
3411
|
var composeWithPendingUploads = ({
|
|
3411
3412
|
composer,
|
|
3412
3413
|
state
|
|
3413
3414
|
}) => {
|
|
3414
3415
|
const composerIsKeptAsDraft = composer.retainsCompositionOnSubmit;
|
|
3415
3416
|
const relevantAttachments = composer.attachmentManager.attachments.filter(
|
|
3416
|
-
(attachment) =>
|
|
3417
|
+
(attachment) => isSendable(attachment) || !composerIsKeptAsDraft && (isPendingUpload(attachment) || isFailedUpload(attachment))
|
|
3417
3418
|
);
|
|
3418
3419
|
const localAttachments = (state.localMessage.attachments ?? []).concat(
|
|
3419
|
-
//
|
|
3420
|
+
// A finished upload or a non-upload is final; the rest keep `localMetadata` (joined to the upload
|
|
3421
|
+
// record).
|
|
3420
3422
|
relevantAttachments.map(
|
|
3421
|
-
(attachment) =>
|
|
3423
|
+
(attachment) => isSendable(attachment) ? localAttachmentToAttachment(attachment) : attachment
|
|
3422
3424
|
)
|
|
3423
3425
|
);
|
|
3424
3426
|
const messageAttachments = (state.message.attachments ?? []).concat(
|
|
3425
|
-
relevantAttachments.filter(
|
|
3427
|
+
relevantAttachments.filter(isSendable).map(localAttachmentToAttachment)
|
|
3426
3428
|
);
|
|
3427
3429
|
if (!localAttachments.length && !messageAttachments.length) return state;
|
|
3428
3430
|
return {
|
|
@@ -3465,7 +3467,7 @@ var createAttachmentsCompositionMiddleware = (composer) => ({
|
|
|
3465
3467
|
return discard();
|
|
3466
3468
|
}
|
|
3467
3469
|
const attachments = (state.message.attachments ?? []).concat(
|
|
3468
|
-
attachmentManager.
|
|
3470
|
+
attachmentManager.attachments.filter(isSendable).map(localAttachmentToAttachment)
|
|
3469
3471
|
);
|
|
3470
3472
|
if (!attachments.length) return forward();
|
|
3471
3473
|
return next({
|
|
@@ -3492,9 +3494,9 @@ var createDraftAttachmentsCompositionMiddleware = (composer) => ({
|
|
|
3492
3494
|
}) => {
|
|
3493
3495
|
const { attachmentManager } = composer;
|
|
3494
3496
|
if (!attachmentManager) return forward();
|
|
3495
|
-
const
|
|
3496
|
-
const attachments =
|
|
3497
|
-
|
|
3497
|
+
const sendableAttachments = attachmentManager.attachments.filter(isSendable);
|
|
3498
|
+
const attachments = sendableAttachments.length ? (state.draft.attachments ?? []).concat(
|
|
3499
|
+
sendableAttachments.map(localAttachmentToAttachment)
|
|
3498
3500
|
) : void 0;
|
|
3499
3501
|
return next({
|
|
3500
3502
|
...state,
|
|
@@ -6915,10 +6917,12 @@ var BasePaginator = class {
|
|
|
6915
6917
|
const claims = claimsActiveInterval ?? this.decidesActiveInterval({ queryShape: forcedQueryShape, reset, updateState });
|
|
6916
6918
|
const activeIntervalClaim = claims ? this.claimActiveInterval() : void 0;
|
|
6917
6919
|
const isForcedReset = reset === "yes" && !keepPreviousItems;
|
|
6920
|
+
let positionBeforeReset;
|
|
6918
6921
|
if (isForcedReset) {
|
|
6919
6922
|
this.clearItemStorage();
|
|
6920
6923
|
this.state.next(this.getStateBeforeFirstQuery());
|
|
6921
6924
|
} else if (reset === "yes" && !forcedQueryShape) {
|
|
6925
|
+
positionBeforeReset = { cursor: this.cursor, offset: this.offset };
|
|
6922
6926
|
this.state.partialNext({
|
|
6923
6927
|
cursor: this.config.initialCursor,
|
|
6924
6928
|
offset: this.config.initialOffset ?? 0
|
|
@@ -6967,6 +6971,7 @@ var BasePaginator = class {
|
|
|
6967
6971
|
direction,
|
|
6968
6972
|
isFirstPage,
|
|
6969
6973
|
keepPreviousItems,
|
|
6974
|
+
positionBeforeReset,
|
|
6970
6975
|
queryShape,
|
|
6971
6976
|
requestedPageSize: this.getRequestedPageSize(queryShape),
|
|
6972
6977
|
updateState
|
|
@@ -6982,7 +6987,10 @@ var BasePaginator = class {
|
|
|
6982
6987
|
this._lastQueryShape = params.queryShape;
|
|
6983
6988
|
const { results } = params;
|
|
6984
6989
|
if (!results) {
|
|
6985
|
-
const stateUpdate = {
|
|
6990
|
+
const stateUpdate = {
|
|
6991
|
+
isLoading: false,
|
|
6992
|
+
...params.positionBeforeReset
|
|
6993
|
+
};
|
|
6986
6994
|
this.state.partialNext(stateUpdate);
|
|
6987
6995
|
return { stateCandidate: stateUpdate, targetInterval: null };
|
|
6988
6996
|
}
|
|
@@ -7417,6 +7425,12 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7417
7425
|
this._itemsLoadedFromOfflineDB = false;
|
|
7418
7426
|
/** The query in flight refreshes a cache-only interval, so its response replaces the interval. */
|
|
7419
7427
|
this._replaceOfflineSeedOnResponse = false;
|
|
7428
|
+
/** Whether `recoverLoadedItems` runs: its pages own the list's position until it ends. */
|
|
7429
|
+
this._isRecoveringLoadedItems = false;
|
|
7430
|
+
/** A recovery asked for while one runs: the running pass stops and a new one starts. */
|
|
7431
|
+
this._recoveryRequestedAgain = false;
|
|
7432
|
+
/** A next page refused while recovering, queried once the recovery ends. See `executeQuery`. */
|
|
7433
|
+
this._tailQueryAwaitingRecovery = false;
|
|
7420
7434
|
/**
|
|
7421
7435
|
* Filters sent with the next query and used as the offline-db query key. Built from the local
|
|
7422
7436
|
* filters only: the backend-resolved filter would change the query shape after the first response,
|
|
@@ -7444,11 +7458,15 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7444
7458
|
if (cachedQuery.predefinedFilter) {
|
|
7445
7459
|
this.applyPredefinedFilterResponse(cachedQuery.predefinedFilter);
|
|
7446
7460
|
}
|
|
7447
|
-
return this.client.hydrateChannels(
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7461
|
+
return this.client.hydrateChannels(
|
|
7462
|
+
cachedQuery.channels,
|
|
7463
|
+
{
|
|
7464
|
+
offlineMode: true,
|
|
7465
|
+
skipInitialization: []
|
|
7466
|
+
// an empty array clears existing channel messages (no duplicates)
|
|
7467
|
+
},
|
|
7468
|
+
request
|
|
7469
|
+
);
|
|
7452
7470
|
}
|
|
7453
7471
|
} catch (error) {
|
|
7454
7472
|
chatLoggerSystem.getLogger("channel").error(error.message);
|
|
@@ -7489,16 +7507,60 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7489
7507
|
};
|
|
7490
7508
|
/**
|
|
7491
7509
|
* The reconnect refresh. Re-queries every loaded page, then drops the loaded channels no page
|
|
7492
|
-
* returned: they were deleted, left, hidden, or no longer
|
|
7510
|
+
* returned that sort within the re-queried range: they were deleted, left, hidden, or no longer
|
|
7511
|
+
* match the filter. Those sorting below it were not re-queried and stay.
|
|
7493
7512
|
*
|
|
7494
7513
|
* Each page asks for everything still to cover and the next one starts where it ended, so the
|
|
7495
7514
|
* server's page cap decides the step. A failed page removes nothing. At most
|
|
7496
|
-
* {@link MAX_RECOVERED_ITEMS} channels are re-queried
|
|
7515
|
+
* {@link MAX_RECOVERED_ITEMS} channels are re-queried.
|
|
7516
|
+
*
|
|
7517
|
+
* Paging is held meanwhile: a next page asked for is queried once the recovery ends, as the list
|
|
7518
|
+
* end that asked for it does not ask again when the recovery changed nothing. A query of the
|
|
7519
|
+
* list's own already in flight is waited for, as it would make the recovery's refused.
|
|
7520
|
+
*
|
|
7521
|
+
* A call while a recovery runs returns at once and the running pass starts over from the first page
|
|
7522
|
+
* once its page in flight lands, as the pages before were watched on a connection that is gone.
|
|
7497
7523
|
*/
|
|
7498
7524
|
this.recoverLoadedItems = async () => {
|
|
7525
|
+
if (this._isRecoveringLoadedItems) {
|
|
7526
|
+
this._recoveryRequestedAgain = true;
|
|
7527
|
+
return;
|
|
7528
|
+
}
|
|
7529
|
+
this._isRecoveringLoadedItems = true;
|
|
7530
|
+
try {
|
|
7531
|
+
do {
|
|
7532
|
+
this._recoveryRequestedAgain = false;
|
|
7533
|
+
await this.waitForQueryToSettle();
|
|
7534
|
+
await this.recoverLoadedPages();
|
|
7535
|
+
} while (this._recoveryRequestedAgain);
|
|
7536
|
+
} finally {
|
|
7537
|
+
this._isRecoveringLoadedItems = false;
|
|
7538
|
+
}
|
|
7539
|
+
if (!this._tailQueryAwaitingRecovery) return;
|
|
7540
|
+
this._tailQueryAwaitingRecovery = false;
|
|
7541
|
+
runDetached(this.toTail(), { context: "ChannelPaginator.recoverLoadedItems" });
|
|
7542
|
+
};
|
|
7543
|
+
/** Resolves once the list has no query of its own in flight. */
|
|
7544
|
+
this.waitForQueryToSettle = () => new Promise((resolve) => {
|
|
7545
|
+
if (!this.isLoading) {
|
|
7546
|
+
resolve();
|
|
7547
|
+
return;
|
|
7548
|
+
}
|
|
7549
|
+
const unsubscribe = this.state.subscribeWithSelector(
|
|
7550
|
+
({ isLoading }) => ({ isLoading }),
|
|
7551
|
+
({ isLoading }) => {
|
|
7552
|
+
if (isLoading) return;
|
|
7553
|
+
unsubscribe();
|
|
7554
|
+
resolve();
|
|
7555
|
+
}
|
|
7556
|
+
);
|
|
7557
|
+
});
|
|
7558
|
+
this.recoverLoadedPages = async () => {
|
|
7499
7559
|
const loadedCids = new Set((this.items ?? []).map((channel) => channel.cid));
|
|
7500
7560
|
const recoveredCount = Math.min(loadedCids.size, MAX_RECOVERED_ITEMS);
|
|
7501
7561
|
const returnedCids = /* @__PURE__ */ new Set();
|
|
7562
|
+
let lastReturnedCid;
|
|
7563
|
+
let reachedEnd = false;
|
|
7502
7564
|
const shape = this.getNextQueryShape();
|
|
7503
7565
|
let interval = null;
|
|
7504
7566
|
let offset = 0;
|
|
@@ -7513,21 +7575,36 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7513
7575
|
updateState: false
|
|
7514
7576
|
});
|
|
7515
7577
|
const page = this.getLastPageCids();
|
|
7516
|
-
if (!result || !page)
|
|
7578
|
+
if (!result || !page || this._recoveryRequestedAgain) {
|
|
7579
|
+
this.state.partialNext({ offset: this.items?.length ?? 0 });
|
|
7580
|
+
return;
|
|
7581
|
+
}
|
|
7517
7582
|
if (result.targetInterval) {
|
|
7518
7583
|
interval = result.targetInterval;
|
|
7519
7584
|
this.setActiveInterval(interval, { updateState: offset === 0 });
|
|
7520
7585
|
}
|
|
7586
|
+
const requested = offset === 0 ? Math.max(this.pageSize, loadedCids.size) : recoveredCount - offset;
|
|
7587
|
+
if (page.length < Math.min(this.pageSize, requested)) reachedEnd = true;
|
|
7521
7588
|
if (!page.length) break;
|
|
7522
7589
|
pageCount++;
|
|
7523
7590
|
for (const channel of result.stateCandidate.items ?? [])
|
|
7524
7591
|
returnedCids.add(channel.cid);
|
|
7592
|
+
lastReturnedCid = page[page.length - 1];
|
|
7525
7593
|
offset += page.length;
|
|
7526
7594
|
} while (offset < recoveredCount);
|
|
7595
|
+
const lastReturned = lastReturnedCid ? this.client.channelManager.get(lastReturnedCid) : void 0;
|
|
7596
|
+
const isWithinRecoveredRange = (cid) => {
|
|
7597
|
+
if (reachedEnd) return true;
|
|
7598
|
+
const channel = this.getItem(cid);
|
|
7599
|
+
if (!channel || !lastReturned) return false;
|
|
7600
|
+
return this.sortComparator(channel, lastReturned) < 0;
|
|
7601
|
+
};
|
|
7527
7602
|
this.batch(
|
|
7528
7603
|
() => {
|
|
7529
7604
|
for (const cid of loadedCids) {
|
|
7530
|
-
if (!returnedCids.has(cid)
|
|
7605
|
+
if (!returnedCids.has(cid) && isWithinRecoveredRange(cid)) {
|
|
7606
|
+
this.removeItem({ id: cid });
|
|
7607
|
+
}
|
|
7531
7608
|
}
|
|
7532
7609
|
},
|
|
7533
7610
|
{ coalesce: true }
|
|
@@ -7661,8 +7738,14 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7661
7738
|
* The metadata describes the query as a whole, so it is committed only when a first page lands (a
|
|
7662
7739
|
* failed query keeps the loaded list's). It is committed before `super`, which filters and ingests
|
|
7663
7740
|
* the page using `matchesFilter` and the comparator this metadata feeds.
|
|
7741
|
+
*
|
|
7742
|
+
* A recovery page (see `recoverLoadedItems`) starts where the one before it ended, so it extends
|
|
7743
|
+
* the shown interval, though a page at a caller's shape would otherwise start one of its own.
|
|
7664
7744
|
*/
|
|
7665
7745
|
placeQueryPage(params) {
|
|
7746
|
+
if (this._isRecoveringLoadedItems && params.startsSeparateInterval) {
|
|
7747
|
+
params = { ...params, startsSeparateInterval: false };
|
|
7748
|
+
}
|
|
7666
7749
|
this._lastPageCids = params.results?.items.map((channel) => channel.cid);
|
|
7667
7750
|
const pendingPredefinedFilter = this._pendingPredefinedFilter;
|
|
7668
7751
|
this._pendingPredefinedFilter = void 0;
|
|
@@ -7740,6 +7823,10 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7740
7823
|
* network is not deferred.
|
|
7741
7824
|
*/
|
|
7742
7825
|
async executeQuery(params = {}) {
|
|
7826
|
+
if (this._isRecoveringLoadedItems && params.direction && params.reset !== "yes") {
|
|
7827
|
+
if (params.direction === "tailward") this._tailQueryAwaitingRecovery = true;
|
|
7828
|
+
return;
|
|
7829
|
+
}
|
|
7743
7830
|
const { offlineDb } = this.client;
|
|
7744
7831
|
const effectiveParams = this._itemsLoadedFromOfflineDB && params.reset !== "yes" ? { ...params, keepPreviousItems: true, reset: "yes" } : params;
|
|
7745
7832
|
const queryShape = effectiveParams.queryShape ?? this.getNextQueryShape();
|
|
@@ -7818,6 +7905,7 @@ var ChannelPaginator = class extends BasePaginator {
|
|
|
7818
7905
|
super.resetState();
|
|
7819
7906
|
this._itemIndex.clear();
|
|
7820
7907
|
this._queryAwaitingSync = void 0;
|
|
7908
|
+
this._tailQueryAwaitingRecovery = false;
|
|
7821
7909
|
}
|
|
7822
7910
|
removeItem(params) {
|
|
7823
7911
|
const coordinates = super.removeItem(params);
|
|
@@ -15335,6 +15423,30 @@ var ChannelApi = class {
|
|
|
15335
15423
|
requestOptions
|
|
15336
15424
|
);
|
|
15337
15425
|
}
|
|
15426
|
+
fork(request, requestOptions) {
|
|
15427
|
+
if (!this.id) {
|
|
15428
|
+
throw new Error(
|
|
15429
|
+
`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`
|
|
15430
|
+
);
|
|
15431
|
+
}
|
|
15432
|
+
return this.chatApi.forkChannel(
|
|
15433
|
+
{ id: this.id, type: this.type },
|
|
15434
|
+
request,
|
|
15435
|
+
requestOptions
|
|
15436
|
+
);
|
|
15437
|
+
}
|
|
15438
|
+
forkMessageIDs(request, requestOptions) {
|
|
15439
|
+
if (!this.id) {
|
|
15440
|
+
throw new Error(
|
|
15441
|
+
`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`
|
|
15442
|
+
);
|
|
15443
|
+
}
|
|
15444
|
+
return this.chatApi.forkMessageIDs(
|
|
15445
|
+
{ id: this.id, type: this.type },
|
|
15446
|
+
request,
|
|
15447
|
+
requestOptions
|
|
15448
|
+
);
|
|
15449
|
+
}
|
|
15338
15450
|
hide(request, requestOptions) {
|
|
15339
15451
|
if (!this.id) {
|
|
15340
15452
|
throw new Error(
|
|
@@ -15443,6 +15555,18 @@ var ChannelApi = class {
|
|
|
15443
15555
|
requestOptions
|
|
15444
15556
|
);
|
|
15445
15557
|
}
|
|
15558
|
+
rewind(request, requestOptions) {
|
|
15559
|
+
if (!this.id) {
|
|
15560
|
+
throw new Error(
|
|
15561
|
+
`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`
|
|
15562
|
+
);
|
|
15563
|
+
}
|
|
15564
|
+
return this.chatApi.rewindChannel(
|
|
15565
|
+
{ id: this.id, type: this.type },
|
|
15566
|
+
request,
|
|
15567
|
+
requestOptions
|
|
15568
|
+
);
|
|
15569
|
+
}
|
|
15446
15570
|
show(request, requestOptions) {
|
|
15447
15571
|
if (!this.id) {
|
|
15448
15572
|
throw new Error(
|
|
@@ -17130,8 +17254,7 @@ var Channel = class extends ChannelApi {
|
|
|
17130
17254
|
if (event.user?.id && event.created_at != null) {
|
|
17131
17255
|
const eventUser = event.user;
|
|
17132
17256
|
const createdAt = event.created_at;
|
|
17133
|
-
const
|
|
17134
|
-
const resolvedDeliveredAt = Number.isFinite(parsedDeliveredAt) ? msToNs(parsedDeliveredAt) : createdAt;
|
|
17257
|
+
const resolvedDeliveredAt = event.last_delivered_at ?? createdAt;
|
|
17135
17258
|
this._upsertReadState(
|
|
17136
17259
|
eventUser.id,
|
|
17137
17260
|
(currentUserReadState) => {
|
|
@@ -19269,6 +19392,17 @@ var ModerationApi = class {
|
|
|
19269
19392
|
requestOptions
|
|
19270
19393
|
);
|
|
19271
19394
|
}
|
|
19395
|
+
revealMedia(request, requestOptions) {
|
|
19396
|
+
return this.apiClient.sendRequest(
|
|
19397
|
+
"POST",
|
|
19398
|
+
"/api/v2/moderation/reveal_media",
|
|
19399
|
+
void 0,
|
|
19400
|
+
void 0,
|
|
19401
|
+
request,
|
|
19402
|
+
"application/json",
|
|
19403
|
+
requestOptions
|
|
19404
|
+
);
|
|
19405
|
+
}
|
|
19272
19406
|
queryReviewQueue(request, requestOptions) {
|
|
19273
19407
|
return this.apiClient.sendRequest(
|
|
19274
19408
|
"POST",
|
|
@@ -19961,9 +20095,14 @@ function applyOwnVoteDelta(state, {
|
|
|
19961
20095
|
}
|
|
19962
20096
|
voteCount = Math.max(voteCount - 1, 0);
|
|
19963
20097
|
if (latestVotesByOption?.[optionId]) {
|
|
19964
|
-
|
|
20098
|
+
const latestVotes = latestVotesByOption[optionId].filter(
|
|
19965
20099
|
(latestVote) => latestVote.id !== vote.id
|
|
19966
20100
|
);
|
|
20101
|
+
if (latestVotes.length) {
|
|
20102
|
+
latestVotesByOption[optionId] = latestVotes;
|
|
20103
|
+
} else {
|
|
20104
|
+
delete latestVotesByOption[optionId];
|
|
20105
|
+
}
|
|
19967
20106
|
}
|
|
19968
20107
|
}
|
|
19969
20108
|
for (const vote of add) {
|
|
@@ -20825,8 +20964,8 @@ var _ChannelManager = class _ChannelManager extends WithSubscriptions {
|
|
|
20825
20964
|
* watches by default), those below it come back through `restoreInterruptedWatch`.
|
|
20826
20965
|
* Never-queried paginators are skipped: they run their own first query on mount, and querying them
|
|
20827
20966
|
* here would race it. Unlike {@link ChannelManager.reload}, it merges the page into the loaded
|
|
20828
|
-
* list (`keepPreviousItems`) instead of blanking it
|
|
20829
|
-
*
|
|
20967
|
+
* list (`keepPreviousItems`) instead of blanking it. Its pages are `silent` so paging is held while it
|
|
20968
|
+
* runs and a recovery asked for meanwhile supersedes it (see `ChannelPaginator.recoverLoadedItems`).
|
|
20830
20969
|
*/
|
|
20831
20970
|
this.recover = async () => await Promise.allSettled(
|
|
20832
20971
|
this.paginators.filter((paginator) => paginator.isInitialized).map(async (paginator) => {
|
|
@@ -21842,6 +21981,10 @@ var StableWSConnection = class {
|
|
|
21842
21981
|
if (data.type === "health.check" || data.type === "connection.ok") {
|
|
21843
21982
|
this.scheduleNextPing();
|
|
21844
21983
|
}
|
|
21984
|
+
if (data?.type === "connection.error" && data?.error?.code === chatCodes.TOKEN_EXPIRED) {
|
|
21985
|
+
logger15.withExtraTags("onmessage").debug("The server reported that the token expired.", { wsID: wsId });
|
|
21986
|
+
this.tokenExpiredByServer = true;
|
|
21987
|
+
}
|
|
21845
21988
|
this.client.dispatchEvent(decodedData);
|
|
21846
21989
|
this.scheduleConnectionCheck();
|
|
21847
21990
|
};
|
|
@@ -21868,7 +22011,7 @@ var StableWSConnection = class {
|
|
|
21868
22011
|
logger15.withExtraTags("onclose").warn("The WebSocket connection was closed. Attempting to reconnect.", {
|
|
21869
22012
|
event
|
|
21870
22013
|
});
|
|
21871
|
-
this.
|
|
22014
|
+
this._reconnectAfterFailure();
|
|
21872
22015
|
}
|
|
21873
22016
|
};
|
|
21874
22017
|
this.onerror = (wsId, event) => {
|
|
@@ -21879,7 +22022,7 @@ var StableWSConnection = class {
|
|
|
21879
22022
|
this.isConnecting = false;
|
|
21880
22023
|
this.rejectPromise?.(this._errorFromWSEvent(event));
|
|
21881
22024
|
logger15.withExtraTags("onerror").warn("The WebSocket connection raised an error.", { event });
|
|
21882
|
-
this.
|
|
22025
|
+
this._reconnectAfterFailure();
|
|
21883
22026
|
};
|
|
21884
22027
|
/** Applies a status change; on a drop, marks the channel watches as interrupted. */
|
|
21885
22028
|
this._setHealth = (healthy) => {
|
|
@@ -21916,6 +22059,7 @@ var StableWSConnection = class {
|
|
|
21916
22059
|
};
|
|
21917
22060
|
this._setupConnectionPromise = () => {
|
|
21918
22061
|
this.isResolved = false;
|
|
22062
|
+
this.tokenExpiredByServer = false;
|
|
21919
22063
|
this.connectionOpen = new Promise((resolve, reject) => {
|
|
21920
22064
|
this.resolvePromise = resolve;
|
|
21921
22065
|
this.rejectPromise = reject;
|
|
@@ -21961,6 +22105,7 @@ var StableWSConnection = class {
|
|
|
21961
22105
|
this.isHealthy = false;
|
|
21962
22106
|
this.wsID = 1;
|
|
21963
22107
|
this.lastEvent = null;
|
|
22108
|
+
this.tokenExpiredByServer = false;
|
|
21964
22109
|
}
|
|
21965
22110
|
/** Read live from the parent, so a config update reaches an already open socket. */
|
|
21966
22111
|
get config() {
|
|
@@ -22069,6 +22214,7 @@ var StableWSConnection = class {
|
|
|
22069
22214
|
this.wsID += 1;
|
|
22070
22215
|
this.isConnecting = false;
|
|
22071
22216
|
this.isDisconnected = true;
|
|
22217
|
+
this.tokenExpiredByServer = false;
|
|
22072
22218
|
this.client.connectionIdManager.invalidate();
|
|
22073
22219
|
if (this.healthCheckTimeoutRef) {
|
|
22074
22220
|
clearTimeout(this.healthCheckTimeoutRef);
|
|
@@ -22173,7 +22319,19 @@ var StableWSConnection = class {
|
|
|
22173
22319
|
logger15.withExtraTags("_reconnect").info("Destroying the current WebSocket connection.");
|
|
22174
22320
|
this._destroyCurrentWSConnection();
|
|
22175
22321
|
if (options.refreshToken) {
|
|
22176
|
-
|
|
22322
|
+
try {
|
|
22323
|
+
await this.client.tokenManager.loadToken();
|
|
22324
|
+
} catch (error) {
|
|
22325
|
+
this._applyHealth(false);
|
|
22326
|
+
this.consecutiveFailures += 1;
|
|
22327
|
+
logger15.withExtraTags("_reconnect").warn("Failed to reload the token. Retrying the reconnect.", { error });
|
|
22328
|
+
this._reconnect({ refreshToken: true });
|
|
22329
|
+
return;
|
|
22330
|
+
}
|
|
22331
|
+
if (this.isConnecting || this.isHealthy) {
|
|
22332
|
+
logger15.withExtraTags("_reconnect").debug("Aborting the reconnect: already connecting or healthy.");
|
|
22333
|
+
return;
|
|
22334
|
+
}
|
|
22177
22335
|
}
|
|
22178
22336
|
try {
|
|
22179
22337
|
await this._connect();
|
|
@@ -22216,6 +22374,19 @@ var StableWSConnection = class {
|
|
|
22216
22374
|
this._reconnect({ interval: WS_NETWORK_RECOVERY_RETRY_MS });
|
|
22217
22375
|
}
|
|
22218
22376
|
}
|
|
22377
|
+
/**
|
|
22378
|
+
* _reconnectAfterFailure - Reconnects after the socket closed or failed. If the server
|
|
22379
|
+
* reported that the token expired, the token is refreshed before reconnecting.
|
|
22380
|
+
* Static tokens cannot be refreshed and reconnect as before.
|
|
22381
|
+
*/
|
|
22382
|
+
_reconnectAfterFailure() {
|
|
22383
|
+
if (this.tokenExpiredByServer && !this.client.tokenManager.isStatic()) {
|
|
22384
|
+
logger15.withExtraTags("_reconnectAfterFailure").info("The token expired. Reloading the token and reconnecting.");
|
|
22385
|
+
this._reconnect({ refreshToken: true });
|
|
22386
|
+
return;
|
|
22387
|
+
}
|
|
22388
|
+
this._reconnect();
|
|
22389
|
+
}
|
|
22219
22390
|
/**
|
|
22220
22391
|
* Writes the status to the field and to `client.wsConnection.state`, and drops the connection ID
|
|
22221
22392
|
* when it goes down. Returns whether the status changed. Every transition goes through here
|
|
@@ -23490,6 +23661,28 @@ var ChatApi = class {
|
|
|
23490
23661
|
requestOptions
|
|
23491
23662
|
);
|
|
23492
23663
|
}
|
|
23664
|
+
forkChannel(pathParams, request, requestOptions) {
|
|
23665
|
+
return this.apiClient.sendRequest(
|
|
23666
|
+
"POST",
|
|
23667
|
+
"/api/v2/chat/channels/{type}/{id}/fork",
|
|
23668
|
+
pathParams,
|
|
23669
|
+
void 0,
|
|
23670
|
+
request,
|
|
23671
|
+
"application/json",
|
|
23672
|
+
requestOptions
|
|
23673
|
+
);
|
|
23674
|
+
}
|
|
23675
|
+
forkMessageIDs(pathParams, request, requestOptions) {
|
|
23676
|
+
return this.apiClient.sendRequest(
|
|
23677
|
+
"POST",
|
|
23678
|
+
"/api/v2/chat/channels/{type}/{id}/fork/message_ids",
|
|
23679
|
+
pathParams,
|
|
23680
|
+
void 0,
|
|
23681
|
+
request,
|
|
23682
|
+
"application/json",
|
|
23683
|
+
requestOptions
|
|
23684
|
+
);
|
|
23685
|
+
}
|
|
23493
23686
|
hideChannel(pathParams, request, requestOptions) {
|
|
23494
23687
|
return this.apiClient.sendRequest(
|
|
23495
23688
|
"POST",
|
|
@@ -23591,6 +23784,17 @@ var ChatApi = class {
|
|
|
23591
23784
|
requestOptions
|
|
23592
23785
|
);
|
|
23593
23786
|
}
|
|
23787
|
+
rewindChannel(pathParams, request, requestOptions) {
|
|
23788
|
+
return this.apiClient.sendRequest(
|
|
23789
|
+
"POST",
|
|
23790
|
+
"/api/v2/chat/channels/{type}/{id}/rewind",
|
|
23791
|
+
pathParams,
|
|
23792
|
+
void 0,
|
|
23793
|
+
request,
|
|
23794
|
+
"application/json",
|
|
23795
|
+
requestOptions
|
|
23796
|
+
);
|
|
23797
|
+
}
|
|
23594
23798
|
showChannel(pathParams, request, requestOptions) {
|
|
23595
23799
|
return this.apiClient.sendRequest(
|
|
23596
23800
|
"POST",
|
|
@@ -24004,12 +24208,12 @@ var ChatApi = class {
|
|
|
24004
24208
|
requestOptions
|
|
24005
24209
|
);
|
|
24006
24210
|
}
|
|
24007
|
-
unreadCounts(
|
|
24211
|
+
unreadCounts(request, requestOptions) {
|
|
24008
24212
|
return this.apiClient.sendRequest(
|
|
24009
24213
|
"GET",
|
|
24010
24214
|
"/api/v2/chat/unread",
|
|
24011
24215
|
void 0,
|
|
24012
|
-
|
|
24216
|
+
request,
|
|
24013
24217
|
void 0,
|
|
24014
24218
|
void 0,
|
|
24015
24219
|
requestOptions
|
|
@@ -24867,7 +25071,7 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
24867
25071
|
return this.userAgent;
|
|
24868
25072
|
}
|
|
24869
25073
|
if (!this.cachedUserAgent) {
|
|
24870
|
-
const version = "10.0.0-rc.
|
|
25074
|
+
const version = "10.0.0-rc.27";
|
|
24871
25075
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
24872
25076
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
24873
25077
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|