git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 47416e4ca950ed7de91562f1c6ede9486e4aa6d9

Files: 47416e4ca950ed7de91562f1c6ede9486e4aa6d9 / modules / page / html / render / message.js

1181 bytesRaw
1var { h, when, send, Value, Proxy, watch } = require('mutant')
2var pull = require('pull-stream')
3var nest = require('depnest')
4var ref = require('ssb-ref')
5
6exports.needs = nest({
7 'keys.sync.id': 'first',
8 'feed.html.thread': 'first',
9 'message.html.render': 'first',
10 'sbot.async.get': 'first'
11})
12
13exports.gives = nest('page.html.render')
14
15exports.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