git ssb

2+

mixmix / ticktack



Tree: 7e24f761d4772ef1ac78ab33da6743bb7e1d821d

Files: 7e24f761d4772ef1ac78ab33da6743bb7e1d821d / app / page / threadShow.js

1389 bytesRaw
1const nest = require('depnest')
2const { h, computed, when } = require('mutant')
3const last = require('lodash/last')
4const get = require('lodash/get')
5
6exports.gives = nest('app.page.threadShow')
7
8exports.needs = nest({
9 'app.html.context': 'first',
10 'app.html.thread': 'first',
11 'message.html.compose': 'first',
12 'unread.sync.markRead': 'first'
13})
14
15exports.create = (api) => {
16 return nest('app.page.threadShow', threadShow)
17
18 function threadShow (location) {
19 // location = a thread (message, may be decorated with replies)
20 const { key, value } = location
21 const root = get(value, 'content.root', key)
22 const channel = get(value, 'content.channel')
23
24 const thread = api.app.html.thread(root)
25
26 //mark the thread as read, as it's being displayed.
27 api.unread.sync.markRead(location)
28 location.replies.forEach(api.unread.sync.markRead)
29
30 const meta = {
31 type: 'post',
32 root,
33 //XXX incorrect branch
34 branch: get(last(location.replies), 'key'),
35 // >> lastId? CHECK THIS LOGIC
36 channel,
37 recps: get(location, 'value.content.recps')
38 }
39 const composer = api.message.html.compose({ meta, shrink: false })
40
41 return h('Page -threadShow', [
42 api.app.html.context(location),
43 h('div.content', [
44 when(thread.subject, h('h1', thread.subject)),
45 thread,
46 composer
47 ]),
48 ])
49 }
50}
51
52
53
54

Built with git-ssb-web