@liveblocks/emails 2.17.0 → 2.18.0-yjsfactory

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/index.js CHANGED
@@ -3,7 +3,7 @@ var _core = require('@liveblocks/core');
3
3
 
4
4
  // src/version.ts
5
5
  var PKG_NAME = "@liveblocks/emails";
6
- var PKG_VERSION = "2.17.0";
6
+ var PKG_VERSION = "2.18.0-yjsfactory";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // ../../node_modules/lib0/map.js
@@ -8544,14 +8544,22 @@ function filterCommentsWithBody(comments) {
8544
8544
  // src/thread-notification.tsx
8545
8545
  var getUnreadComments = ({
8546
8546
  comments,
8547
+ previousUnreadInboxNotification,
8547
8548
  inboxNotification,
8548
8549
  userId
8549
8550
  }) => {
8550
8551
  const commentsWithBody = filterCommentsWithBody(comments);
8552
+ const otherUserComments = commentsWithBody.filter((c) => c.userId !== userId);
8551
8553
  const readAt = inboxNotification.readAt;
8552
- return commentsWithBody.filter((c) => c.userId !== userId).filter(
8553
- (c) => readAt ? c.createdAt > readAt && c.createdAt <= inboxNotification.notifiedAt : c.createdAt <= inboxNotification.notifiedAt
8554
- );
8554
+ return otherUserComments.filter((c) => {
8555
+ if (readAt !== null) {
8556
+ return c.createdAt > readAt && c.createdAt <= inboxNotification.notifiedAt;
8557
+ }
8558
+ if (previousUnreadInboxNotification !== null) {
8559
+ return c.createdAt >= previousUnreadInboxNotification.notifiedAt && c.createdAt <= inboxNotification.notifiedAt;
8560
+ }
8561
+ return c.createdAt <= inboxNotification.notifiedAt;
8562
+ });
8555
8563
  };
8556
8564
  var getLastUnreadCommentWithMention = ({
8557
8565
  comments,
@@ -8567,12 +8575,17 @@ var extractThreadNotificationData = async ({
8567
8575
  event
8568
8576
  }) => {
8569
8577
  const { threadId, roomId, userId, inboxNotificationId } = event.data;
8570
- const [thread, inboxNotification] = await Promise.all([
8578
+ const [thread, inboxNotification, { data: inboxNotifications }] = await Promise.all([
8571
8579
  client.getThread({ roomId, threadId }),
8572
- client.getInboxNotification({ inboxNotificationId, userId })
8580
+ client.getInboxNotification({ inboxNotificationId, userId }),
8581
+ client.getInboxNotifications({ userId, query: { unread: true } })
8573
8582
  ]);
8583
+ const previousUnreadInboxNotification = _nullishCoalesce(inboxNotifications.sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime()).filter(
8584
+ ({ id: id2, kind }) => kind === "thread" && id2 !== inboxNotification.id
8585
+ )[0], () => ( null));
8574
8586
  const unreadComments = getUnreadComments({
8575
8587
  comments: thread.comments,
8588
+ previousUnreadInboxNotification,
8576
8589
  inboxNotification,
8577
8590
  userId
8578
8591
  });