git ssb

2+

mixmix / ticktack



Tree: b10ce2e3fb81fd4e7ded0080858d4a7ff1d508f9

Files: b10ce2e3fb81fd4e7ded0080858d4a7ff1d508f9 / app / html / comments.js

1621 bytesRaw
1const nest = require('depnest')
2const { h, Array: MutantArray, map, computed, when, resolve } = require('mutant')
3const get = require('lodash/get')
4
5exports.gives = nest('app.html.comments')
6
7exports.needs = nest({
8 'about.html.avatar': 'first',
9 'about.obs.name': 'first',
10 'feed.obs.thread': 'first',
11 'keys.sync.id': 'first',
12 'message.html.markdown': 'first',
13 'message.html.timeago': 'first',
14 'message.html.likes': 'first',
15 'unread.sync.markRead': 'first',
16 'unread.sync.isUnread': 'first',
17})
18
19exports.create = (api) => {
20 return nest('app.html.comments', comments)
21
22 function comments (root) {
23 const myId = api.keys.sync.id()
24 const { messages } = api.feed.obs.thread(root)
25
26 return h('Comments',
27 map(messages, Comment)
28 )
29
30 function Comment (msgObs) {
31 const msg = resolve(msgObs)
32 const raw = get(msg, 'value.content.text')
33 var className = api.unread.sync.isUnread(msg) ? ' -unread' : ' -read'
34 api.unread.sync.markRead(msg)
35
36 if (!get(msg, 'value.content.root')) return
37
38 const { author } = msg.value
39 return h('Comment', { className }, [
40 h('div.left', api.about.html.avatar(author, 'tiny')),
41 h('div.right', [
42 h('section.context', [
43 h('div.name', api.about.obs.name(author)),
44 api.message.html.timeago(msg)
45 ]),
46 h('section.content', api.message.html.markdown(raw)),
47 h('section.actions', [
48 h('div.reply', [
49 h('i.fa.fa-commenting-o'),
50 ]),
51 api.message.html.likes(msg)
52 ])
53 ])
54 ])
55 }
56 }
57}
58
59

Built with git-ssb-web