stream-chat 10.0.0-rc.14 → 10.0.0-rc.15
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/dist/cjs/index.browser.js +23 -13
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +23 -13
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +23 -13
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/channel.d.ts +10 -4
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +3 -2
- package/dist/types/types.d.ts +0 -6
- package/package.json +1 -1
- package/src/channel.ts +15 -12
- package/src/client.ts +1 -4
- package/src/configuration/shape.ts +6 -0
- package/src/messageDelivery/MessageDeliveryReporter.ts +18 -7
- package/src/types.ts +0 -6
- package/src/utils.ts +1 -2
|
@@ -552,7 +552,7 @@ var channelHasReadEvents = (channel) => {
|
|
|
552
552
|
const ownCapabilities = channel?.data?.own_capabilities;
|
|
553
553
|
return !(Array.isArray(ownCapabilities) && !ownCapabilities.includes("read-events"));
|
|
554
554
|
};
|
|
555
|
-
var channelTracksReadLocally = (channel) => !channelHasReadEvents(channel) && !!channel?.
|
|
555
|
+
var channelTracksReadLocally = (channel) => !channelHasReadEvents(channel) && !!channel?.config.readEvents.localUnreadCountEnabled;
|
|
556
556
|
function retryInterval(numberOfFailures) {
|
|
557
557
|
const max = Math.min(500 + numberOfFailures * 2e3, 25e3);
|
|
558
558
|
const min = Math.min(Math.max(250, (numberOfFailures - 1) * 2e3), 25e3);
|
|
@@ -14478,11 +14478,12 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
14478
14478
|
}, this.requestTimeoutMs);
|
|
14479
14479
|
};
|
|
14480
14480
|
/**
|
|
14481
|
-
* Delegates the mark-read call to the Channel or Thread instance.
|
|
14481
|
+
* Delegates the mark-read call to the Channel or Thread instance. A channel whose read events are
|
|
14482
|
+
* disabled is marked read locally instead, when the client opted into counting unread itself.
|
|
14482
14483
|
*
|
|
14483
14484
|
* @param collection - The channel or thread to mark as read.
|
|
14484
14485
|
* @param options - Flags forwarded to the underlying `markRead` call (optional).
|
|
14485
|
-
* @returns The server response, or `null` when
|
|
14486
|
+
* @returns The server response, or `null` when no request went out.
|
|
14486
14487
|
*/
|
|
14487
14488
|
this.markRead = async (collection, options) => {
|
|
14488
14489
|
const isThreadCollection = isThread(collection);
|
|
@@ -14496,8 +14497,15 @@ var MessageDeliveryReporter = class _MessageDeliveryReporter {
|
|
|
14496
14497
|
thread: collection
|
|
14497
14498
|
}) ?? null : await channel.markRead(requestOptions);
|
|
14498
14499
|
} else {
|
|
14499
|
-
const
|
|
14500
|
-
|
|
14500
|
+
const { readEvents, requestHandlers } = channel.configState.getLatestValue();
|
|
14501
|
+
const markReadRequestHandler = requestHandlers?.markReadRequest;
|
|
14502
|
+
if (markReadRequestHandler) {
|
|
14503
|
+
result = await markReadRequestHandler({ channel, options: requestOptions }) ?? null;
|
|
14504
|
+
} else if (!readEvents.enabled && readEvents.localUnreadCountEnabled) {
|
|
14505
|
+
channel.markReadLocally();
|
|
14506
|
+
} else {
|
|
14507
|
+
result = await channel.markRead(requestOptions);
|
|
14508
|
+
}
|
|
14501
14509
|
}
|
|
14502
14510
|
if (result) this.removeCandidateFor(collection);
|
|
14503
14511
|
return result;
|
|
@@ -15451,7 +15459,7 @@ var ownDeclarativeConfig = (slice) => {
|
|
|
15451
15459
|
var DEFAULT_CHANNEL_CONFIG = deepFreezeConfig({
|
|
15452
15460
|
availableCommands: [],
|
|
15453
15461
|
deliveryEvents: { enabled: true },
|
|
15454
|
-
readEvents: { enabled: true },
|
|
15462
|
+
readEvents: { enabled: true, localUnreadCountEnabled: false },
|
|
15455
15463
|
replies: { enabled: true },
|
|
15456
15464
|
typingEvents: { enabled: true },
|
|
15457
15465
|
userMessageReminders: { enabled: true }
|
|
@@ -16478,7 +16486,7 @@ var Channel = class extends WithMessageOperations(ChannelApi) {
|
|
|
16478
16486
|
/**
|
|
16479
16487
|
* Resets this user's unread count locally, without any backend call. Intended for
|
|
16480
16488
|
* channels that have read events disabled (e.g. livestreams) when the client is created with the
|
|
16481
|
-
* `
|
|
16489
|
+
* `readEvents.localUnreadCountEnabled` configuration. Dispatches a dedicated, client-only `message.read_locally` event
|
|
16482
16490
|
* that runs through the same `_handleChannelEvent` read logic as a real `message.read` (minus the
|
|
16483
16491
|
* delivery-report network sync), so the read-state update lives in one place. When offline support
|
|
16484
16492
|
* is enabled, the offline DB persists the reset for read-events-disabled channels, so the local
|
|
@@ -16640,7 +16648,7 @@ var Channel = class extends WithMessageOperations(ChannelApi) {
|
|
|
16640
16648
|
if (message.user?.id === this.getClient().userId) return false;
|
|
16641
16649
|
if (message.user?.id && this.getClient().userMuteStatus(message.user.id))
|
|
16642
16650
|
return false;
|
|
16643
|
-
if (!this.
|
|
16651
|
+
if (!this.config.readEvents.localUnreadCountEnabled && !channelHasReadEvents(this)) {
|
|
16644
16652
|
return false;
|
|
16645
16653
|
}
|
|
16646
16654
|
if (this.muteStatus().muted) return false;
|
|
@@ -24412,7 +24420,7 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
24412
24420
|
return this.userAgent;
|
|
24413
24421
|
}
|
|
24414
24422
|
if (!this.cachedUserAgent) {
|
|
24415
|
-
const version = "10.0.0-rc.
|
|
24423
|
+
const version = "10.0.0-rc.15";
|
|
24416
24424
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
24417
24425
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
24418
24426
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
@@ -24468,10 +24476,7 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
24468
24476
|
this.uploadManager = new UploadManager(this);
|
|
24469
24477
|
this.browser = options.browser ?? typeof window !== "undefined";
|
|
24470
24478
|
this.node = !this.browser;
|
|
24471
|
-
this.options = {
|
|
24472
|
-
isLocalUnreadCountEnabled: false,
|
|
24473
|
-
...options
|
|
24474
|
-
};
|
|
24479
|
+
this.options = { ...options };
|
|
24475
24480
|
this.axiosInstance = import_axios4.default.create({
|
|
24476
24481
|
timeout: 3e3,
|
|
24477
24482
|
withCredentials: false,
|
|
@@ -25961,6 +25966,11 @@ var CHANNEL_FIELDS = {
|
|
|
25961
25966
|
description: 'Allows marking the channel read or unread. The server must also allow it per channel type (`read_events`), and a server "no" wins.',
|
|
25962
25967
|
kind: "value",
|
|
25963
25968
|
type: "boolean"
|
|
25969
|
+
},
|
|
25970
|
+
localUnreadCountEnabled: {
|
|
25971
|
+
description: "Counts unread messages client-side when `enabled` is false, reset by `channel.markReadLocally()` instead of a request. Not subject to server authority.",
|
|
25972
|
+
kind: "value",
|
|
25973
|
+
type: "boolean"
|
|
25964
25974
|
}
|
|
25965
25975
|
},
|
|
25966
25976
|
kind: "group"
|