From f55db679e7071e72b3e21d00d52c725196f23f01 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 15 Oct 2022 19:37:46 +0000 Subject: [PATCH] Allow to create posts with multiple object links --- src/api/posts.ts | 2 +- src/components/Post.vue | 26 ++++++++++++-------------- src/components/PostContent.vue | 7 +++---- src/components/PostEditor.vue | 30 +++++++++++++++--------------- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/api/posts.ts b/src/api/posts.ts index ae8c33d..635cb8f 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -72,7 +72,7 @@ export interface Post { ipfs_cid: string | null; token_id: number | null; token_tx_id: string | null; - quote: Post | null; + links: Post[]; } export async function getHomeTimeline( diff --git a/src/components/Post.vue b/src/components/Post.vue index 68c640a..b751ac7 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -66,24 +66,25 @@ >
- + - {{ getQuoteAuthorDisplayName() }} + {{ getQuoteAuthorDisplayName(linkedPost) }} - @{{ getActorAddress(post.quote.account) }} + @{{ getActorAddress(linkedPost.account) }}
- -
+ +
@@ -336,11 +337,8 @@ function getReplyMentions(): Mention[] { return props.post.mentions } -function getQuoteAuthorDisplayName(): string | null { - if (props.post.quote === null) { - return null - } - const profile = new ProfileWrapper(props.post.quote.account) +function getQuoteAuthorDisplayName(post: Post): string | null { + const profile = new ProfileWrapper(post.account) return profile.getDisplayName() } diff --git a/src/components/PostContent.vue b/src/components/PostContent.vue index be5ae97..055b584 100644 --- a/src/components/PostContent.vue +++ b/src/components/PostContent.vue @@ -56,14 +56,13 @@ function configureInlineLinks() { }) } } - const quote = props.post.quote - if (quote) { + for (const linkedPost of props.post.links) { const links = postContentRef.querySelectorAll("a") for (const linkElement of Array.from(links)) { - if (quote.uri === linkElement.getAttribute("href")) { + if (linkedPost.uri === linkElement.getAttribute("href")) { linkElement.addEventListener("click", (event: Event) => { event.preventDefault() - router.push({ name: "post", params: { postId: quote.id } }) + router.push({ name: "post", params: { postId: linkedPost.id } }) }) } } diff --git a/src/components/PostEditor.vue b/src/components/PostEditor.vue index 228e12b..d1ded3f 100644 --- a/src/components/PostEditor.vue +++ b/src/components/PostEditor.vue @@ -33,10 +33,10 @@
@@ -159,10 +159,10 @@ const attachmentUploadInputRef = $ref(null) let content = $ref("") let attachments = $ref([]) -let quote = $ref(null) +let linkList = $ref(null) let visibility = $ref(Visibility.Public) -let quoteInputVisible = $ref(false) +let linkListInputVisible = $ref(false) let visibilityMenuVisible = $ref(false) let isLoading = $ref(false) let errorMessage = $ref(null) @@ -221,7 +221,7 @@ function removeAttachment(index: number) { attachments.splice(index, 1) } -function canAddQuote(): boolean { +function canAddLink(): boolean { return props.inReplyTo === null && visibility === Visibility.Public } @@ -251,7 +251,7 @@ async function publish(contentType = "text/markdown") { in_reply_to_id: props.inReplyTo ? props.inReplyTo.id : null, visibility: visibility, mentions: [], - links: quote ? [quote] : [], + links: linkList ? linkList.split(",") : [], attachments: attachments, } isLoading = true @@ -271,8 +271,8 @@ async function publish(contentType = "text/markdown") { isLoading = false content = "" attachments = [] - quote = null - quoteInputVisible = false + linkList = null + linkListInputVisible = false if (postFormContentRef) { await nextTick() triggerResize(postFormContentRef) @@ -345,7 +345,7 @@ $line-height: 1.5; } } -#quote { +#link-list { border-top: 1px solid $separator-color; line-height: $line-height; padding: calc($block-inner-padding / 1.5) $block-inner-padding;