Basic 'Replying to' in Posts

This commit is contained in:
styppo 2022-12-23 21:49:26 +00:00
parent 9d2bb8982a
commit 028e870f5f
No known key found for this signature in database
GPG Key ID: 3AAA685C50724C28
2 changed files with 23 additions and 2 deletions

View File

@ -46,7 +46,7 @@ export default {
} }
</script> </script>
<style lang="scss"> <style lang="scss" scoped>
@import 'assets/theme/colors.scss'; @import 'assets/theme/colors.scss';
a { a {

View File

@ -13,6 +13,9 @@
<span>&#183;</span> <span>&#183;</span>
<span class="created-at">{{ moment(post.createdAt).fromNow() }}</span> <span class="created-at">{{ moment(post.createdAt).fromNow() }}</span>
</p> </p>
<p v-if="post.inReplyTo" class="in-reply-to">
Replying to <a @click.stop="toEvent(post.inReplyTo)">{{ shorten(post.inReplyTo) }}</a>
</p>
</div> </div>
<div class="post-content-body"> <div class="post-content-body">
<p> <p>
@ -84,11 +87,15 @@ function countRepliesRecursive(event) {
function postFromEvents(events) { function postFromEvents(events) {
const event = events[0] const event = events[0]
if (event.interpolated.replyEvents.length) {
console.log(event.content, event.interpolated.replyEvents)
}
return { return {
id: event.id, id: event.id,
author: event.pubkey, author: event.pubkey,
createdAt: event.created_at * 1000, createdAt: event.created_at * 1000,
content: event.content, content: event.content,
inReplyTo: event.interpolated.replyEvents[event.interpolated.replyEvents.length - 1],
images: [], images: [],
stats: { stats: {
comments: countRepliesRecursive(event), comments: countRepliesRecursive(event),
@ -153,8 +160,22 @@ export default {
margin-left: 12px; margin-left: 12px;
flex-grow: 1; flex-grow: 1;
&-header { &-header {
.in-reply-to {
color: $color-dark-gray;
a {
color: $color-blue;
&:hover {
text-decoration: underline;
}
}
}
p { p {
margin: 0 0 8px; &:first-child {
margin: 0;
}
&:last-child {
margin: 0 0 8px;
}
> span { > span {
color: $color-dark-gray; color: $color-dark-gray;
&:first-child { &:first-child {