Add post sub-type to post renderer

This commit is contained in:
Christian Bundy 2019-11-29 12:50:18 -08:00
parent e596f17a9e
commit 03a894b133
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
2 changed files with 16 additions and 4 deletions

View File

@ -99,7 +99,7 @@ const transform = (ssb, messages, myFeedId) =>
// [ @key, @key, @key ]
const voters = Object
.entries(reducedVotes)
.filter(([key, value]) => value === 1)
.filter(([, value]) => value === 1)
.map(([key]) => key)
const pendingName = cooler.get(
@ -149,6 +149,16 @@ const transform = (ssb, messages, myFeedId) =>
url: avatarUrl
})
if (isRoot(msg)) {
lodash.set(msg, 'value.meta.postType', 'posted')
} else if (isReply(msg)) {
lodash.set(msg, 'value.meta.postType', 'replied to thread')
} else if (isNestedReply(msg)) {
lodash.set(msg, 'value.meta.postType', 'replied to message')
} else {
lodash.set(msg, 'value.meta.postType', 'published a mysterious message')
}
lodash.set(msg, 'value.meta.votes', voters)
lodash.set(msg, 'value.meta.voted', voters.includes(myFeedId))

View File

@ -2,7 +2,6 @@
const {
a,
abbr,
article,
button,
details,
@ -112,8 +111,11 @@ module.exports = ({ msg }) => {
span({ class: 'text' },
span({ class: 'author' },
a({ href: url.author }, name)),
span({ class: 'timestamp' }, ` ${timeAgo} ago`),
isPrivate ? abbr({ title: 'private' }, '🔒') : null)),
isPrivate ? ' privately 🔒' : null,
span(` ${msg.value.meta.postType}`),
span(` ${timeAgo} ago`),
':'
)),
articleContent,
// HACK: centered-footer