Handle clicks on quotes

This commit is contained in:
silverpill 2022-08-22 12:18:06 +00:00
parent 41c3c95aa3
commit d77e98aa31
2 changed files with 19 additions and 6 deletions

View file

@ -66,6 +66,7 @@ export interface Post {
ipfs_cid: string | null;
token_id: number | null;
token_tx_id: string | null;
quote: Post | null;
}
export async function getHomeTimeline(

View file

@ -275,15 +275,27 @@ onMounted(() => {
}
const mentions = postContentRef.getElementsByClassName("mention")
for (const mentionElement of Array.from(mentions)) {
mentionElement.addEventListener("click", (event: Event) => {
event.preventDefault()
const mention = props.post.mentions
.find((mention) => mention.url === mentionElement.getAttribute("href"))
if (mention) {
mentionElement.addEventListener("click", (event: Event) => {
event.preventDefault()
router.push({ name: "profile", params: { profileId: mention.id } })
}
})
}
}
const quote = props.post.quote
if (quote) {
const quotes = postContentRef.querySelectorAll(".quote-inline a")
for (const quoteElement of Array.from(quotes)) {
if (quote.uri === quoteElement.getAttribute("href")) {
quoteElement.addEventListener("click", (event: Event) => {
event.preventDefault()
router.push({ name: "post", params: { postId: quote.id } })
})
}
}
}
})
function highlight(postId: string | null) {