Files: 971db96b011c54c34ce17deebe0068e374754022 / modules / page / html / render / message.js
1181 bytesRaw
1 | var { h, when, send, Value, Proxy, watch } = require('mutant') |
2 | var pull = require('pull-stream') |
3 | var nest = require('depnest') |
4 | var ref = require('ssb-ref') |
5 | |
6 | exports.needs = nest({ |
7 | 'keys.sync.id': 'first', |
8 | 'feed.html.thread': 'first', |
9 | 'message.html.render': 'first', |
10 | 'sbot.async.get': 'first' |
11 | }) |
12 | |
13 | exports.gives = nest('page.html.render') |
14 | |
15 | exports.create = function (api) { |
16 | return nest('page.html.render', function channel (id) { |
17 | if (!ref.isMsg(id)) return |
18 | var loader = h('div', {className: 'Loading -large'}) |
19 | var result = Proxy(loader) |
20 | |
21 | api.sbot.async.get(id, (err, value) => { |
22 | if (err) return result.set(h('div', {className: 'Error'}, ['Cannot load thead'])) |
23 | if (value.content.root) { |
24 | result.set(h('div', {className: 'FeedEvent'}, [ |
25 | h('a.full', {href: value.content.root}, ['View full thread']), |
26 | h('div.replies', [ |
27 | api.message.html.render({key: id, value}) |
28 | ]) |
29 | ])) |
30 | } else { |
31 | var thread = api.feed.html.thread(id) |
32 | result.set(when(thread.sync, thread, loader)) |
33 | } |
34 | }) |
35 | |
36 | return h('div', {className: 'SplitView'}, [ |
37 | h('div.main', result) |
38 | ]) |
39 | }) |
40 | } |
41 |
Built with git-ssb-web