stream-chat 9.47.1 → 9.49.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/dist/cjs/index.browser.js +54 -25
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +54 -25
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +54 -25
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/channel.d.ts +2 -2
- package/dist/types/client.d.ts +4 -2
- package/dist/types/custom_types.d.ts +2 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/thread.d.ts +2 -0
- package/dist/types/types.d.ts +55 -14
- package/package.json +1 -1
- package/src/channel.ts +2 -2
- package/src/client.ts +46 -28
- package/src/custom_types.ts +1 -0
- package/src/index.ts +1 -0
- package/src/thread.ts +29 -0
- package/src/thread_manager.ts +1 -0
- package/src/types.ts +66 -14
package/dist/esm/index.mjs
CHANGED
|
@@ -7435,6 +7435,7 @@ var Thread = class extends WithSubscriptions {
|
|
|
7435
7435
|
this.addUnsubscribeFunction(this.subscribeMarkThreadStale());
|
|
7436
7436
|
this.addUnsubscribeFunction(this.subscribeNewReplies());
|
|
7437
7437
|
this.addUnsubscribeFunction(this.subscribeRepliesRead());
|
|
7438
|
+
this.addUnsubscribeFunction(this.subscribeRepliesUnread());
|
|
7438
7439
|
this.addUnsubscribeFunction(this.subscribeMessageDeleted());
|
|
7439
7440
|
this.addUnsubscribeFunction(this.subscribeMessageUpdated());
|
|
7440
7441
|
};
|
|
@@ -7476,6 +7477,26 @@ var Thread = class extends WithSubscriptions {
|
|
|
7476
7477
|
}
|
|
7477
7478
|
this.state.partialNext({ isStateStale: true });
|
|
7478
7479
|
}).unsubscribe;
|
|
7480
|
+
this.subscribeRepliesUnread = () => this.client.on("notification.mark_unread", (event) => {
|
|
7481
|
+
if (!event.user || !event.created_at || !event.thread_id) return;
|
|
7482
|
+
if (event.thread_id !== this.id) return;
|
|
7483
|
+
const userId = event.user.id;
|
|
7484
|
+
const createdAt = event.created_at;
|
|
7485
|
+
const user = event.user;
|
|
7486
|
+
this.state.next((current) => ({
|
|
7487
|
+
...current,
|
|
7488
|
+
read: {
|
|
7489
|
+
...current.read,
|
|
7490
|
+
[userId]: {
|
|
7491
|
+
...current.read[userId],
|
|
7492
|
+
lastReadAt: typeof event.last_read_at !== "undefined" ? new Date(event.last_read_at) : new Date(createdAt),
|
|
7493
|
+
user,
|
|
7494
|
+
firstUnreadMessageId: event.first_unread_message_id,
|
|
7495
|
+
unreadMessageCount: event.unread_messages ?? 0
|
|
7496
|
+
}
|
|
7497
|
+
}
|
|
7498
|
+
}));
|
|
7499
|
+
}).unsubscribe;
|
|
7479
7500
|
this.subscribeNewReplies = () => this.client.on("message.new", (event) => {
|
|
7480
7501
|
if (!this.client.userID || event.message?.parent_id !== this.id) {
|
|
7481
7502
|
return;
|
|
@@ -12403,6 +12424,7 @@ var ThreadManager = class extends WithSubscriptions {
|
|
|
12403
12424
|
const unsubscribeFunctions = [
|
|
12404
12425
|
"health.check",
|
|
12405
12426
|
"notification.mark_read",
|
|
12427
|
+
"notification.mark_unread",
|
|
12406
12428
|
"notification.thread_message_new",
|
|
12407
12429
|
"notification.channel_deleted"
|
|
12408
12430
|
].map(
|
|
@@ -14590,6 +14612,31 @@ var StreamChat = class _StreamChat {
|
|
|
14590
14612
|
* @return {Promise<APIResponse>}
|
|
14591
14613
|
*/
|
|
14592
14614
|
this.markAllRead = this.markChannelsRead;
|
|
14615
|
+
this.getUserAgent = () => {
|
|
14616
|
+
if (this.userAgent) {
|
|
14617
|
+
return this.userAgent;
|
|
14618
|
+
}
|
|
14619
|
+
if (!this.cachedUserAgent) {
|
|
14620
|
+
const version = "9.49.0";
|
|
14621
|
+
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
14622
|
+
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
14623
|
+
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
14624
|
+
const head = sdkName ? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version}` : `stream-chat-js-v${version}-${this.node ? "node" : "browser"}`;
|
|
14625
|
+
this.cachedUserAgent = [
|
|
14626
|
+
head,
|
|
14627
|
+
// reports the host app, the device OS, the device model, and the picked
|
|
14628
|
+
// exports bundle, each only when a value is present
|
|
14629
|
+
...Object.entries({
|
|
14630
|
+
app: appName,
|
|
14631
|
+
app_version: appVersion,
|
|
14632
|
+
os,
|
|
14633
|
+
device_model: deviceModel,
|
|
14634
|
+
client_bundle: "browser-esm"
|
|
14635
|
+
}).filter(([, value]) => value && value.length > 0).map(([key, value]) => `${key}=${value}`)
|
|
14636
|
+
].join("|");
|
|
14637
|
+
}
|
|
14638
|
+
return this.cachedUserAgent;
|
|
14639
|
+
};
|
|
14593
14640
|
/**
|
|
14594
14641
|
* _isUsingServerAuth - Returns true if we're using server side auth
|
|
14595
14642
|
*/
|
|
@@ -15042,6 +15089,13 @@ var StreamChat = class _StreamChat {
|
|
|
15042
15089
|
delete this.activeChannels[cid];
|
|
15043
15090
|
});
|
|
15044
15091
|
}
|
|
15092
|
+
if (event.type === "notification.removed_from_channel" && event.cid) {
|
|
15093
|
+
const { cid } = event;
|
|
15094
|
+
this.activeChannels[cid]?._disconnect();
|
|
15095
|
+
postListenerCallbacks.push(() => {
|
|
15096
|
+
delete this.activeChannels[cid];
|
|
15097
|
+
});
|
|
15098
|
+
}
|
|
15045
15099
|
return postListenerCallbacks;
|
|
15046
15100
|
}
|
|
15047
15101
|
_muteStatus(cid) {
|
|
@@ -16533,31 +16587,6 @@ var StreamChat = class _StreamChat {
|
|
|
16533
16587
|
partialThreadObject
|
|
16534
16588
|
);
|
|
16535
16589
|
}
|
|
16536
|
-
getUserAgent() {
|
|
16537
|
-
if (this.userAgent) {
|
|
16538
|
-
return this.userAgent;
|
|
16539
|
-
}
|
|
16540
|
-
const version = "9.47.1";
|
|
16541
|
-
const clientBundle = "browser-esm";
|
|
16542
|
-
let userAgentString = "";
|
|
16543
|
-
if (this.sdkIdentifier) {
|
|
16544
|
-
userAgentString = `stream-chat-${this.sdkIdentifier.name}-v${this.sdkIdentifier.version}-llc-v${version}`;
|
|
16545
|
-
} else {
|
|
16546
|
-
userAgentString = `stream-chat-js-v${version}-${this.node ? "node" : "browser"}`;
|
|
16547
|
-
}
|
|
16548
|
-
const { os, model } = this.deviceIdentifier ?? {};
|
|
16549
|
-
return [
|
|
16550
|
-
// reports the device OS, if provided
|
|
16551
|
-
["os", os],
|
|
16552
|
-
// reports the device model, if provided
|
|
16553
|
-
["device_model", model],
|
|
16554
|
-
// reports which bundle is being picked from the exports
|
|
16555
|
-
["client_bundle", clientBundle]
|
|
16556
|
-
].reduce(
|
|
16557
|
-
(withArguments, [key, value]) => value && value.length > 0 ? withArguments.concat(`|${key}=${value}`) : withArguments,
|
|
16558
|
-
userAgentString
|
|
16559
|
-
);
|
|
16560
|
-
}
|
|
16561
16590
|
/**
|
|
16562
16591
|
* @deprecated use sdkIdentifier instead
|
|
16563
16592
|
* @param userAgent
|