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