From 388bf2c7f289d5e1f7610f5cd31839641073bfd3 Mon Sep 17 00:00:00 2001 From: aumetra Date: Sat, 7 Oct 2023 19:40:44 +0200 Subject: [PATCH] add attachment rendering --- kitsune-fe/src/components/BaseTimeline.vue | 1 + kitsune-fe/src/components/Post.vue | 105 +++++++++++++-------- kitsune-fe/src/graphql/timeline.ts | 5 + kitsune-fe/src/graphql/types/gql.ts | 6 +- kitsune-fe/src/graphql/types/graphql.ts | 27 ++++++ 5 files changed, 104 insertions(+), 40 deletions(-) diff --git a/kitsune-fe/src/components/BaseTimeline.vue b/kitsune-fe/src/components/BaseTimeline.vue index 4acdd0d64..eeb7ed996 100644 --- a/kitsune-fe/src/components/BaseTimeline.vue +++ b/kitsune-fe/src/components/BaseTimeline.vue @@ -24,6 +24,7 @@ :account="item.account" :subject="item.subject" :content="item.content" + :attachments="item.attachments" /> diff --git a/kitsune-fe/src/components/Post.vue b/kitsune-fe/src/components/Post.vue index 980c00bdd..ef1ea5a34 100644 --- a/kitsune-fe/src/components/Post.vue +++ b/kitsune-fe/src/components/Post.vue @@ -1,26 +1,38 @@ @@ -38,10 +50,17 @@ url: string; }; + export type PostAttachment = { + contentType: string; + description?: string | null; + url: string; + }; + export type Post = { subject?: string | null; content: string; account: PostAccount; + attachments: PostAttachment[]; }; const props = defineProps(); @@ -55,37 +74,49 @@ diff --git a/kitsune-fe/src/graphql/timeline.ts b/kitsune-fe/src/graphql/timeline.ts index 79738c91c..5e3395572 100644 --- a/kitsune-fe/src/graphql/timeline.ts +++ b/kitsune-fe/src/graphql/timeline.ts @@ -22,6 +22,11 @@ function getHome() { username url } + attachments { + contentType + description + url + } } pageInfo { startCursor diff --git a/kitsune-fe/src/graphql/types/gql.ts b/kitsune-fe/src/graphql/types/gql.ts index 2db3b2cd5..900545c40 100644 --- a/kitsune-fe/src/graphql/types/gql.ts +++ b/kitsune-fe/src/graphql/types/gql.ts @@ -18,7 +18,7 @@ const documents = { types.RegisterUserDocument, '\n query getInstanceInfo {\n instance {\n description\n domain\n localPostCount\n registrationsOpen\n name\n userCount\n version\n captcha {\n backend\n key\n }\n }\n }\n ': types.GetInstanceInfoDocument, - '\n query getHomeTimeline {\n homeTimeline(before: "00000000-0000-0000-0000-000000000000")\n @_relayPagination(mergeMode: "after") {\n nodes {\n id\n subject\n content\n url\n account {\n id\n avatar {\n url\n }\n displayName\n username\n url\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n ': + '\n query getHomeTimeline {\n homeTimeline(before: "00000000-0000-0000-0000-000000000000")\n @_relayPagination(mergeMode: "after") {\n nodes {\n id\n subject\n content\n url\n account {\n id\n avatar {\n url\n }\n displayName\n username\n url\n }\n attachments {\n contentType\n description\n url\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n ': types.GetHomeTimelineDocument, '\n mutation registerOauthApplication(\n $name: String!\n $redirect_uri: String!\n ) {\n registerOauthApplication(name: $name, redirectUri: $redirect_uri) {\n id\n secret\n redirectUri\n }\n }\n ': types.RegisterOauthApplicationDocument, @@ -54,8 +54,8 @@ export function graphql( * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function graphql( - source: '\n query getHomeTimeline {\n homeTimeline(before: "00000000-0000-0000-0000-000000000000")\n @_relayPagination(mergeMode: "after") {\n nodes {\n id\n subject\n content\n url\n account {\n id\n avatar {\n url\n }\n displayName\n username\n url\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n ', -): (typeof documents)['\n query getHomeTimeline {\n homeTimeline(before: "00000000-0000-0000-0000-000000000000")\n @_relayPagination(mergeMode: "after") {\n nodes {\n id\n subject\n content\n url\n account {\n id\n avatar {\n url\n }\n displayName\n username\n url\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n ']; + source: '\n query getHomeTimeline {\n homeTimeline(before: "00000000-0000-0000-0000-000000000000")\n @_relayPagination(mergeMode: "after") {\n nodes {\n id\n subject\n content\n url\n account {\n id\n avatar {\n url\n }\n displayName\n username\n url\n }\n attachments {\n contentType\n description\n url\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n ', +): (typeof documents)['\n query getHomeTimeline {\n homeTimeline(before: "00000000-0000-0000-0000-000000000000")\n @_relayPagination(mergeMode: "after") {\n nodes {\n id\n subject\n content\n url\n account {\n id\n avatar {\n url\n }\n displayName\n username\n url\n }\n attachments {\n contentType\n description\n url\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n ']; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/kitsune-fe/src/graphql/types/graphql.ts b/kitsune-fe/src/graphql/types/graphql.ts index 2806dca5d..2c0ce6426 100644 --- a/kitsune-fe/src/graphql/types/graphql.ts +++ b/kitsune-fe/src/graphql/types/graphql.ts @@ -305,6 +305,12 @@ export type GetHomeTimelineQuery = { url: string; avatar?: { __typename?: 'MediaAttachment'; url: string } | null; }; + attachments: Array<{ + __typename?: 'MediaAttachment'; + contentType: string; + description?: string | null; + url: string; + }>; }>; pageInfo: { __typename?: 'PageInfo'; @@ -595,6 +601,27 @@ export const GetHomeTimelineDocument = { ], }, }, + { + kind: 'Field', + name: { kind: 'Name', value: 'attachments' }, + selectionSet: { + kind: 'SelectionSet', + selections: [ + { + kind: 'Field', + name: { kind: 'Name', value: 'contentType' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'description' }, + }, + { + kind: 'Field', + name: { kind: 'Name', value: 'url' }, + }, + ], + }, + }, ], }, },