Skip to content

Commit 8fe8b9f

Browse files
committed
PD-4978
1 parent 28339da commit 8fe8b9f

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/app/core/inbox/permission-notifications.service.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,18 @@ describe('PermissionNotificationsService', () => {
322322
})
323323
})
324324

325-
it('should sort by sentDate descending', (done) => {
325+
it('should sort by createdDate descending', (done) => {
326326
const perm1 = createPermissionNotification({
327327
putCode: 1,
328-
sentDate: 1000,
328+
createdDate: 1000,
329329
source: {
330330
sourceClientId: { path: 'client-a' } as any,
331331
sourceName: { content: 'A' },
332332
},
333333
})
334334
const perm2 = createPermissionNotification({
335335
putCode: 2,
336-
sentDate: 3000,
336+
createdDate: 3000,
337337
source: {
338338
sourceClientId: { path: 'client-b' } as any,
339339
sourceName: { content: 'B' },
@@ -346,8 +346,8 @@ describe('PermissionNotificationsService', () => {
346346
)
347347

348348
service.loadUnreadPermissionNotifications(3).subscribe((result) => {
349-
expect(result[0].sentDate).toBe(3000)
350-
expect(result[1].sentDate).toBe(1000)
349+
expect(result[0].createdDate).toBe(3000)
350+
expect(result[1].createdDate).toBe(1000)
351351
done()
352352
})
353353
})

src/app/core/inbox/permission-notifications.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ export class PermissionNotificationsService {
9797
(n): n is InboxNotificationPermission =>
9898
n?.notificationType === 'PERMISSION' && !n.readDate && !n.archivedDate
9999
)
100-
.sort((a, b) => Number(b.createdDate || 0) - Number(a.createdDate || 0))
100+
.sort(
101+
(a, b) =>
102+
new Date(b.createdDate || 0).getTime() -
103+
new Date(a.createdDate || 0).getTime()
104+
)
101105
const byClient = new Map<string, InboxNotificationPermission>()
102106
for (const n of unreadPermission) {
103107
const clientId = n?.source?.sourceClientId?.path
@@ -106,7 +110,9 @@ export class PermissionNotificationsService {
106110
if (!byClient.has(clientId)) byClient.set(clientId, n)
107111
}
108112
return Array.from(byClient.values()).sort(
109-
(a, b) => Number(b.createdDate || 0) - Number(a.createdDate || 0)
113+
(a, b) =>
114+
new Date(b.createdDate || 0).getTime() -
115+
new Date(a.createdDate || 0).getTime()
110116
)
111117
}
112118
}

0 commit comments

Comments
 (0)