Skip to content

Commit

Permalink
Add seenAt time to listNotifications (#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms authored Dec 12, 2023
1 parent 2a99143 commit 0c54951
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lexicons/app/bsky/notification/listNotifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"notifications": {
"type": "array",
"items": { "type": "ref", "ref": "#notification" }
}
},
"seenAt": { "type": "string", "format": "datetime" }
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7325,6 +7325,10 @@ export const schemaDict = {
ref: 'lex:app.bsky.notification.listNotifications#notification',
},
},
seenAt: {
type: 'string',
format: 'datetime',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
notifications: Notification[]
seenAt?: string
[k: string]: unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const presentation = (state: HydrationState) => {
labels: [...recordLabels, ...recordSelfLabels],
}
})
return { notifications, cursor }
return { notifications, cursor, seenAt: lastSeenNotifs }
}

const getRecordMap = async (
Expand Down
4 changes: 4 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7325,6 +7325,10 @@ export const schemaDict = {
ref: 'lex:app.bsky.notification.listNotifications#notification',
},
},
seenAt: {
type: 'string',
format: 'datetime',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
notifications: Notification[]
seenAt?: string
[k: string]: unknown
}

Expand Down
7 changes: 7 additions & 0 deletions packages/bsky/tests/views/notifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ describe('notification views', () => {
encoding: 'application/json',
},
)
const full2 = await agent.api.app.bsky.notification.listNotifications(
{},
{ headers: await network.serviceHeaders(alice) },
)
expect(full2.data.notifications.length).toBe(full.data.notifications.length)
expect(full2.data.seenAt).toEqual(seenAt)

const notifCount = await agent.api.app.bsky.notification.getUnreadCount(
{},
{ headers: await network.serviceHeaders(alice) },
Expand Down
4 changes: 4 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7325,6 +7325,10 @@ export const schemaDict = {
ref: 'lex:app.bsky.notification.listNotifications#notification',
},
},
seenAt: {
type: 'string',
format: 'datetime',
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type InputSchema = undefined
export interface OutputSchema {
cursor?: string
notifications: Notification[]
seenAt?: string
[k: string]: unknown
}

Expand Down

0 comments on commit 0c54951

Please sign in to comment.