Files: 9b70108d00646124112662ec83dd9733d7afca7d / app / page / threadShow.js
1278 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 | 'unread.sync.markRead': 'first' |
13 | }) |
14 | |
15 | exports.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 | //unread state is set in here... |
25 | const thread = api.app.html.thread(root) |
26 | |
27 | const meta = { |
28 | type: 'post', |
29 | root, |
30 | //XXX incorrect branch |
31 | branch: get(last(location.replies), 'key'), |
32 | // >> lastId? CHECK THIS LOGIC |
33 | channel, |
34 | recps: get(location, 'value.content.recps') |
35 | } |
36 | const composer = api.message.html.compose({ meta, shrink: false }) |
37 | |
38 | return h('Page -threadShow', [ |
39 | api.app.html.context(location), |
40 | h('div.content', [ |
41 | when(thread.subject, h('h1', thread.subject)), |
42 | thread, |
43 | composer |
44 | ]), |
45 | ]) |
46 | } |
47 | } |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 |
Built with git-ssb-web