There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(server): correct notification pagination by using 'lt' instead of 'gt' for createdAt (#11430)
fengmk2a5eb1b998518
diff --git a/packages/backend/server/src/__tests__/e2e/notification/resolver.spec.ts b/packages/backend/server/src/__tests__/e2e/notification/resolver.spec.tsindex 5831a1ead1..57a562100d 100644--- a/packages/backend/server/src/__tests__/e2e/notification/resolver.spec.ts+++ b/packages/backend/server/src/__tests__/e2e/notification/resolver.spec.ts@@ -625,24 +625,7 @@ e2e('should list and count notifications', async t => {t.is(body2.workspace!.name, 'test-workspace-name');t.falsy(body2.workspace!.avatarUrl);- await app.login(owner);- await app.gql({- query: mentionUserMutation,- variables: {- input: {- userId: member.id,- workspaceId: workspace.id,- doc: {- id: 'doc-id-5',- title: 'doc-title-5',- blockId: 'block-id-5',- mode: DocMode.page,- },- },- },- });-- // get new notifications+ // load more notificationsawait app.login(member);const result2 = await app.gql({query: listNotificationsQuery,@@ -650,43 +633,43 @@ e2e('should list and count notifications', async t => {pagination: {first: 2,offset: 0,- after: result.currentUser!.notifications.pageInfo.startCursor,+ after: result.currentUser!.notifications.pageInfo.endCursor,},},});- t.is(result2.currentUser!.notifications.totalCount, 5);- t.is(result2.currentUser!.notifications.pageInfo.hasNextPage, false);+ t.is(result2.currentUser!.notifications.totalCount, 4);+ t.is(result2.currentUser!.notifications.pageInfo.hasNextPage, true);t.is(result2.currentUser!.notifications.pageInfo.hasPreviousPage, true);const notifications2 = result2.currentUser!.notifications.edges.map(edge => edge.node) as NotificationObjectType[];- t.is(notifications2.length, 1);+ t.is(notifications2.length, 2);const notification3 = notifications2[0];t.is(notification3.read, false);const body3 = notification3.body as MentionNotificationBodyType;t.is(body3.workspace!.id, workspace.id);- t.is(body3.doc.id, 'doc-id-5');- t.is(body3.doc.title, 'doc-title-5');- t.is(body3.doc.blockId, 'block-id-5');+ t.is(body3.doc.id, 'doc-id-2');+ t.is(body3.doc.title, 'doc-title-2');+ t.is(body3.doc.blockId, 'block-id-2');t.is(body3.createdByUser!.id, owner.id);t.is(body3.createdByUser!.name, owner.name);t.is(body3.workspace!.id, workspace.id);t.is(body3.workspace!.name, 'test-workspace-name');t.falsy(body3.workspace!.avatarUrl);- // no new notifications+ // no notificationsconst result3 = await app.gql({query: listNotificationsQuery,variables: {pagination: {first: 2,offset: 0,- after: result2.currentUser!.notifications.pageInfo.startCursor,+ after: result2.currentUser!.notifications.pageInfo.endCursor,},},});- t.is(result3.currentUser!.notifications.totalCount, 5);+ t.is(result3.currentUser!.notifications.totalCount, 4);t.is(result3.currentUser!.notifications.pageInfo.hasNextPage, false);t.is(result3.currentUser!.notifications.pageInfo.hasPreviousPage, true);t.is(result3.currentUser!.notifications.pageInfo.startCursor, null);diff --git a/packages/backend/server/src/models/notification.ts b/packages/backend/server/src/models/notification.tsindex 0a86662576..7dc88df4a5 100644--- a/packages/backend/server/src/models/notification.ts+++ b/packages/backend/server/src/models/notification.ts@@ -209,7 +209,7 @@ export class NotificationModel extends BaseModel {where: {userId,...(options?.includeRead ? {} : { read: false }),- ...(options?.after ? { createdAt: { gt: options.after } } : {}),+ ...(options?.after ? { createdAt: { lt: options.after } } : {}),},orderBy: { createdAt: 'desc' },skip: options?.offset,