Skip to content

Commit

Permalink
Attach record URI to listItemView (#1758)
Browse files Browse the repository at this point in the history
* feat: attach record uri to listitemview

* chore: attempt to update test snapshots
  • Loading branch information
intrnl authored Dec 1, 2023
1 parent 3be9c74 commit 8d9b1f7
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lexicons/app/bsky/graph/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
},
"listItemView": {
"type": "object",
"required": ["subject"],
"required": ["uri", "subject"],
"properties": {
"uri": { "type": "string", "format": "at-uri" },
"subject": { "type": "ref", "ref": "app.bsky.actor.defs#profileView" }
}
},
Expand Down
6 changes: 5 additions & 1 deletion packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6423,8 +6423,12 @@ export const schemaDict = {
},
listItemView: {
type: 'object',
required: ['subject'],
required: ['uri', 'subject'],
properties: {
uri: {
type: 'string',
format: 'at-uri',
},
subject: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileView',
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/client/types/app/bsky/graph/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult {
}

export interface ListItemView {
uri: string
subject: AppBskyActorDefs.ProfileView
[k: string]: unknown
}
Expand Down
4 changes: 2 additions & 2 deletions packages/bsky/src/api/app/bsky/graph/getList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const presentation = (state: HydrationState, ctx: Context) => {
const items = mapDefined(listItems, (item) => {
const subject = actors[item.did]
if (!subject) return
return { subject }
return { uri: item.uri, subject }
})
return { list: listView, items, cursor }
}
Expand All @@ -122,7 +122,7 @@ type Params = QueryParams & {
type SkeletonState = {
params: Params
list: Actor & ListInfo
listItems: (Actor & { cid: string; sortAt: string })[]
listItems: (Actor & { uri: string; cid: string; sortAt: string })[]
cursor?: string
}

Expand Down
6 changes: 5 additions & 1 deletion packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6423,8 +6423,12 @@ export const schemaDict = {
},
listItemView: {
type: 'object',
required: ['subject'],
required: ['uri', 'subject'],
properties: {
uri: {
type: 'string',
format: 'at-uri',
},
subject: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileView',
Expand Down
1 change: 1 addition & 0 deletions packages/bsky/src/lexicon/types/app/bsky/graph/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult {
}

export interface ListItemView {
uri: string
subject: AppBskyActorDefs.ProfileView
[k: string]: unknown
}
Expand Down
6 changes: 5 additions & 1 deletion packages/bsky/src/services/graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ export class GraphService {
.selectFrom('list_item')
.innerJoin('actor as subject', 'subject.did', 'list_item.subjectDid')
.selectAll('subject')
.select(['list_item.cid as cid', 'list_item.sortAt as sortAt'])
.select([
'list_item.uri as uri',
'list_item.cid as cid',
'list_item.sortAt as sortAt',
])
}

async getBlockAndMuteState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ Object {
"muted": false,
},
},
"uri": "record(4)",
},
Object {
"subject": Object {
Expand Down Expand Up @@ -541,6 +542,7 @@ Object {
"muted": false,
},
},
"uri": "record(5)",
},
],
"list": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ Object {
},
},
},
"uri": "record(3)",
},
Object {
"subject": Object {
Expand Down Expand Up @@ -545,6 +546,7 @@ Object {
},
},
},
"uri": "record(5)",
},
],
"list": Object {
Expand Down
6 changes: 5 additions & 1 deletion packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6423,8 +6423,12 @@ export const schemaDict = {
},
listItemView: {
type: 'object',
required: ['subject'],
required: ['uri', 'subject'],
properties: {
uri: {
type: 'string',
format: 'at-uri',
},
subject: {
type: 'ref',
ref: 'lex:app.bsky.actor.defs#profileView',
Expand Down
1 change: 1 addition & 0 deletions packages/pds/src/lexicon/types/app/bsky/graph/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function validateListView(v: unknown): ValidationResult {
}

export interface ListItemView {
uri: string
subject: AppBskyActorDefs.ProfileView
[k: string]: unknown
}
Expand Down
6 changes: 4 additions & 2 deletions packages/pds/tests/proxied/__snapshots__/views.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3326,6 +3326,7 @@ Object {
"muted": false,
},
},
"uri": "record(3)",
},
Object {
"subject": Object {
Expand All @@ -3341,15 +3342,15 @@ Object {
"cts": "1970-01-01T00:00:00.000Z",
"neg": false,
"src": "user(3)",
"uri": "record(5)",
"uri": "record(7)",
"val": "self-label-a",
},
Object {
"cid": "cids(2)",
"cts": "1970-01-01T00:00:00.000Z",
"neg": false,
"src": "user(3)",
"uri": "record(5)",
"uri": "record(7)",
"val": "self-label-b",
},
],
Expand All @@ -3358,6 +3359,7 @@ Object {
"muted": false,
},
},
"uri": "record(6)",
},
],
"list": Object {
Expand Down

0 comments on commit 8d9b1f7

Please sign in to comment.