Files: d4471ed9e0be3a61e29df8a0de9c3b36cf52e096 / app / page / threadShow.js
1173 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed, when } = require('mutant') |
3 | const last = require('lodash/last') |
4 | const get = require('lodash/get') |
5 | |
6 | exports.gives = nest('app.page.threadShow') |
7 | |
8 | exports.needs = nest({ |
9 | 'app.html.context': 'first', |
10 | 'app.html.thread': 'first', |
11 | 'message.html.compose': 'first' |
12 | }) |
13 | |
14 | exports.create = (api) => { |
15 | return nest('app.page.threadShow', threadShow) |
16 | |
17 | function threadShow (location) { |
18 | // location = a thread (message, may be decorated with replies) |
19 | const { key, value } = location |
20 | const root = get(value, 'content.root', key) |
21 | const channel = get(value, 'content.channel') |
22 | |
23 | const thread = api.app.html.thread(root) |
24 | |
25 | const meta = { |
26 | type: 'post', |
27 | root, |
28 | branch: get(last(location.replies), 'key'), |
29 | // >> lastId? CHECK THIS LOGIC |
30 | channel, |
31 | recps: get(location, 'value.content.recps') |
32 | } |
33 | const composer = api.message.html.compose({ meta, shrink: false }) |
34 | |
35 | return h('Page -threadShow', [ |
36 | api.app.html.context(location), |
37 | h('div.content', [ |
38 | when(thread.subject, h('h1', thread.subject)), |
39 | thread, |
40 | composer |
41 | ]), |
42 | ]) |
43 | } |
44 | } |
45 | |
46 | |
47 |
Built with git-ssb-web