stream-chat-react 14.11.0 → 14.11.1

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/es/index.mjs CHANGED
@@ -19792,18 +19792,27 @@ var ChannelListItem = (props) => {
19792
19792
  const isActive = typeof active === "undefined" ? activeChannel?.cid === channel.cid : active;
19793
19793
  const { muted } = useIsChannelMuted(channel);
19794
19794
  useEffect(() => {
19795
- const handleEvent = (event) => {
19795
+ const handleChannelReadStateChange = (event) => {
19796
19796
  if (channel.cid !== event.cid) return;
19797
19797
  if (event.user?.id !== client.user?.id) return;
19798
19798
  setUnread(channel.countUnread());
19799
19799
  };
19800
- client.on("notification.mark_read", handleEvent);
19801
- channel.on("notification.mark_unread", handleEvent);
19802
- channel.on("message.read_locally", handleEvent);
19800
+ const handleMarkRead = (event) => {
19801
+ if (event.thread_id) return;
19802
+ if (event.user && client.user && event.user.id !== client.user.id) return;
19803
+ if (!event.cid) return setUnread(0);
19804
+ if (channel.cid !== event.cid) return;
19805
+ setUnread(0);
19806
+ };
19807
+ client.on("notification.mark_read", handleMarkRead);
19808
+ channel.on("notification.mark_unread", handleChannelReadStateChange);
19809
+ channel.on("message.read_locally", handleChannelReadStateChange);
19810
+ channel.on("message.read", handleChannelReadStateChange);
19803
19811
  return () => {
19804
- client.off("notification.mark_read", handleEvent);
19805
- channel.off("notification.mark_unread", handleEvent);
19806
- channel.off("message.read_locally", handleEvent);
19812
+ client.off("notification.mark_read", handleMarkRead);
19813
+ channel.off("notification.mark_unread", handleChannelReadStateChange);
19814
+ channel.off("message.read_locally", handleChannelReadStateChange);
19815
+ channel.off("message.read", handleChannelReadStateChange);
19807
19816
  };
19808
19817
  }, [channel, client]);
19809
19818
  const refreshUnreadCount = useMemo(() => throttle(() => {
@@ -20592,7 +20601,7 @@ var useChat = ({ client, defaultLanguage = "en", i18nInstance }) => {
20592
20601
  };
20593
20602
  useEffect(() => {
20594
20603
  if (!client) return;
20595
- const version = "14.11.0";
20604
+ const version = "14.11.1";
20596
20605
  const userAgent = client.getUserAgent();
20597
20606
  if (!userAgent.includes("stream-chat-react")) client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
20598
20607
  client.threads.registerSubscriptions();