Files: caccfaabbf34bd8a9c657de74eed2bde040853bd / app / page / threadShow.js
1196 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed } = 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 | 'translations.sync.strings': 'first', |
10 | 'app.html.thread': 'first', |
11 | 'message.html.compose': 'first' |
12 | }) |
13 | |
14 | exports.create = (api) => { |
15 | var strings = api.translations.sync.strings() |
16 | |
17 | return nest('app.page.threadShow', threadShow) |
18 | |
19 | function threadShow (location) { |
20 | // location = a thread (message decorated with replies) |
21 | const { key: root, value } = location |
22 | const channel = get(value, 'content.channel') |
23 | |
24 | const thread = api.app.html.thread(root) |
25 | |
26 | const meta = { |
27 | type: 'post', |
28 | root, |
29 | branch: get(last(location.replies), 'key'), |
30 | // >> lastId? CHECK THIS LOGIC |
31 | channel, |
32 | recps: get(location, 'value.content.recps') |
33 | } |
34 | const composer = api.message.html.compose({ meta, shrink: false }) |
35 | const subject = computed(thread.subject, subject => subject || strings.threadShow) |
36 | |
37 | return h('Page -threadShow', [ |
38 | h('div.container', [ |
39 | h('h1', subject), |
40 | thread, |
41 | composer |
42 | ]), |
43 | ]) |
44 | } |
45 | } |
46 | |
47 | |
48 |
Built with git-ssb-web