git ssb

1+

Daan Patchwork / patchwork



Tree: 3451510316992d414ec76ba5b29681fe359b7428

Files: 3451510316992d414ec76ba5b29681fe359b7428 / lib / depject / page / html / render / participating.js

1501 bytesRaw
1const nest = require('depnest')
2const { h, when } = require('mutant')
3
4exports.needs = nest({
5 'sbot.pull.resumeStream': 'first',
6 'sbot.pull.stream': 'first',
7 'feed.html.rollup': 'first',
8 'keys.sync.id': 'first',
9 'intl.sync.i18n': 'first',
10 'settings.obs.get': 'first'
11})
12
13exports.gives = nest({
14 'page.html.render': true
15})
16
17exports.create = function (api) {
18 const i18n = api.intl.sync.i18n
19 return nest('page.html.render', page)
20
21 function page (path) {
22 if (path !== '/participating') return // "/" is a sigil for "page"
23
24 const includeParticipating = api.settings.obs.get('patchwork.includeParticipating', false)
25
26 const prepend = [
27 when(includeParticipating, null, h('PageHeading', [
28 h('h1', [
29 i18n('Participating')
30 ])
31 ]))
32 ]
33
34 const getStream = api.sbot.pull.resumeStream((sbot, opts) => {
35 return sbot.patchwork.participatingFeed.roots(opts)
36 }, { limit: 10, reverse: true })
37
38 const yourId = api.keys.sync.id()
39
40 const feedView = api.feed.html.rollup(getStream, {
41 prepend,
42 searchSpinner: true,
43 groupSummaries: false,
44 compactFilter: (msg) => msg.value.author === yourId, // condense your messages
45 updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.participatingFeed.latest())
46 })
47
48 const result = h('div.SplitView', [
49 h('div.main', feedView)
50 ])
51
52 result.pendingUpdates = feedView.pendingUpdates
53 result.reload = feedView.reload
54
55 return result
56 }
57}
58

Built with git-ssb-web