Files: 390dfd4c75d9544f0b36ee3341d2ac1852b2ce56 / app / page / threadShow.js
1166 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, replies, channel } = location |
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: channel, |
31 | recps: get(location, 'value.content.recps') |
32 | } |
33 | const composer = api.message.html.compose({ meta, shrink: false }) |
34 | const subject = computed(thread.subject, subject => subject || strings.threadShow) |
35 | |
36 | return h('Page -threadShow', [ |
37 | h('div.container', [ |
38 | h('h1', subject), |
39 | thread, |
40 | composer |
41 | ]), |
42 | ]) |
43 | } |
44 | } |
45 | |
46 | |
47 |
Built with git-ssb-web