@liveblocks/emails 2.17.0-usrnotsettings3 → 2.18.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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise, DRI, CommentBody } from '@liveblocks/core';
1
+ import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, Awaitable, DRI, CommentBody } from '@liveblocks/core';
2
2
  export { ResolveUsersArgs } from '@liveblocks/core';
3
3
  import { ReactNode, ComponentType } from 'react';
4
4
  import { Properties } from 'csstype';
@@ -204,7 +204,7 @@ type PrepareTextMentionNotificationEmailBaseDataOptions = {
204
204
  /**
205
205
  * A function that returns room info from room IDs.
206
206
  */
207
- resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
207
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
208
208
  };
209
209
  type MentionEmailAsReactData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
210
210
  author: U;
@@ -218,7 +218,7 @@ type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta =
218
218
  /**
219
219
  * A function that returns info from user IDs.
220
220
  */
221
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
221
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
222
222
  /**
223
223
  * The components used to customize the resulting React nodes. Each components has
224
224
  * priority over the base components inherited.
@@ -259,7 +259,7 @@ type PrepareTextMentionNotificationEmailAsHtmlOptions<U extends BaseUserMeta = D
259
259
  /**
260
260
  * A function that returns info from user IDs.
261
261
  */
262
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
262
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
263
263
  /**
264
264
  * The styles used to customize the html elements in the resulting html safe string.
265
265
  * Each styles has priority over the base styles inherited.
@@ -306,7 +306,7 @@ type PrepareThreadNotificationEmailBaseDataOptions = {
306
306
  /**
307
307
  * A function that returns room info from room IDs.
308
308
  */
309
- resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
309
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
310
310
  };
311
311
  type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<CommentEmailBaseData, "userId" | "rawBody"> & {
312
312
  author: U;
@@ -331,7 +331,7 @@ type PrepareThreadNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> =
331
331
  /**
332
332
  * A function that returns info from user IDs.
333
333
  */
334
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
334
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
335
335
  /**
336
336
  * The styles used to customize the html elements in the resulting html safe string inside a comment body.
337
337
  * Each styles has priority over the base styles inherited.
@@ -370,7 +370,7 @@ type PrepareThreadNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> =
370
370
  /**
371
371
  * A function that returns info from user IDs.
372
372
  */
373
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
373
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
374
374
  /**
375
375
  * The components used to customize the resulting React nodes inside a comment body.
376
376
  * Each components has priority over the base components inherited internally defined.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, OptionalPromise, DRI, CommentBody } from '@liveblocks/core';
1
+ import { CommentBodyText, CommentBodyLink, BaseUserMeta, DU, CommentBodyMention, ResolveUsersArgs, Awaitable, DRI, CommentBody } from '@liveblocks/core';
2
2
  export { ResolveUsersArgs } from '@liveblocks/core';
3
3
  import { ReactNode, ComponentType } from 'react';
4
4
  import { Properties } from 'csstype';
@@ -204,7 +204,7 @@ type PrepareTextMentionNotificationEmailBaseDataOptions = {
204
204
  /**
205
205
  * A function that returns room info from room IDs.
206
206
  */
207
- resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
207
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
208
208
  };
209
209
  type MentionEmailAsReactData<U extends BaseUserMeta = DU> = Omit<MentionEmailBaseData, "userId" | "textEditorNodes"> & {
210
210
  author: U;
@@ -218,7 +218,7 @@ type PrepareTextMentionNotificationEmailAsReactOptions<U extends BaseUserMeta =
218
218
  /**
219
219
  * A function that returns info from user IDs.
220
220
  */
221
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
221
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
222
222
  /**
223
223
  * The components used to customize the resulting React nodes. Each components has
224
224
  * priority over the base components inherited.
@@ -259,7 +259,7 @@ type PrepareTextMentionNotificationEmailAsHtmlOptions<U extends BaseUserMeta = D
259
259
  /**
260
260
  * A function that returns info from user IDs.
261
261
  */
262
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
262
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
263
263
  /**
264
264
  * The styles used to customize the html elements in the resulting html safe string.
265
265
  * Each styles has priority over the base styles inherited.
@@ -306,7 +306,7 @@ type PrepareThreadNotificationEmailBaseDataOptions = {
306
306
  /**
307
307
  * A function that returns room info from room IDs.
308
308
  */
309
- resolveRoomInfo?: (args: ResolveRoomInfoArgs) => OptionalPromise<DRI | undefined>;
309
+ resolveRoomInfo?: (args: ResolveRoomInfoArgs) => Awaitable<DRI | undefined>;
310
310
  };
311
311
  type CommentEmailAsHtmlData<U extends BaseUserMeta = DU> = Omit<CommentEmailBaseData, "userId" | "rawBody"> & {
312
312
  author: U;
@@ -331,7 +331,7 @@ type PrepareThreadNotificationEmailAsHtmlOptions<U extends BaseUserMeta = DU> =
331
331
  /**
332
332
  * A function that returns info from user IDs.
333
333
  */
334
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
334
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
335
335
  /**
336
336
  * The styles used to customize the html elements in the resulting html safe string inside a comment body.
337
337
  * Each styles has priority over the base styles inherited.
@@ -370,7 +370,7 @@ type PrepareThreadNotificationEmailAsReactOptions<U extends BaseUserMeta = DU> =
370
370
  /**
371
371
  * A function that returns info from user IDs.
372
372
  */
373
- resolveUsers?: (args: ResolveUsersArgs) => OptionalPromise<(U["info"] | undefined)[] | undefined>;
373
+ resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
374
374
  /**
375
375
  * The components used to customize the resulting React nodes inside a comment body.
376
376
  * Each components has priority over the base components inherited internally defined.
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-usrnotsettings3";
6
+ var PKG_VERSION = "2.18.0";
7
7
  var PKG_FORMAT = "cjs";
8
8
 
9
9
  // ../../node_modules/lib0/map.js
@@ -7693,9 +7693,6 @@ function createBatchUsersResolver({
7693
7693
  // src/liveblocks-text-editor.tsx
7694
7694
 
7695
7695
 
7696
-
7697
-
7698
-
7699
7696
  // src/lib/constants.ts
7700
7697
  var MENTION_CHARACTER = "@";
7701
7698
 
@@ -8547,14 +8544,22 @@ function filterCommentsWithBody(comments) {
8547
8544
  // src/thread-notification.tsx
8548
8545
  var getUnreadComments = ({
8549
8546
  comments,
8547
+ previousUnreadInboxNotification,
8550
8548
  inboxNotification,
8551
8549
  userId
8552
8550
  }) => {
8553
8551
  const commentsWithBody = filterCommentsWithBody(comments);
8552
+ const otherUserComments = commentsWithBody.filter((c) => c.userId !== userId);
8554
8553
  const readAt = inboxNotification.readAt;
8555
- return commentsWithBody.filter((c) => c.userId !== userId).filter(
8556
- (c) => readAt ? c.createdAt > readAt && c.createdAt <= inboxNotification.notifiedAt : c.createdAt <= inboxNotification.notifiedAt
8557
- );
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
+ });
8558
8563
  };
8559
8564
  var getLastUnreadCommentWithMention = ({
8560
8565
  comments,
@@ -8570,12 +8575,17 @@ var extractThreadNotificationData = async ({
8570
8575
  event
8571
8576
  }) => {
8572
8577
  const { threadId, roomId, userId, inboxNotificationId } = event.data;
8573
- const [thread, inboxNotification] = await Promise.all([
8578
+ const [thread, inboxNotification, { data: inboxNotifications }] = await Promise.all([
8574
8579
  client.getThread({ roomId, threadId }),
8575
- client.getInboxNotification({ inboxNotificationId, userId })
8580
+ client.getInboxNotification({ inboxNotificationId, userId }),
8581
+ client.getInboxNotifications({ userId, query: { unread: true } })
8576
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));
8577
8586
  const unreadComments = getUnreadComments({
8578
8587
  comments: thread.comments,
8588
+ previousUnreadInboxNotification,
8579
8589
  inboxNotification,
8580
8590
  userId
8581
8591
  });