git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: df3a0af70b34b408b510eafb21126103772656a3

Files: df3a0af70b34b408b510eafb21126103772656a3 / modules / page / html / render / gatherings.js

1395 bytesRaw
1var { h } = require('mutant')
2var nest = require('depnest')
3
4exports.needs = nest({
5 'feed.pull.type': 'first',
6 'feed.html.rollup': 'first',
7 'feed.pull.public': 'first',
8 'gathering.sheet.edit': 'first',
9 'keys.sync.id': 'first',
10 'contact.obs.following': 'first',
11 'sbot.pull.stream': 'first'
12})
13
14exports.gives = nest('page.html.render')
15
16exports.create = function (api) {
17 return nest('page.html.render', function channel (path) {
18 if (path !== '/gatherings') return
19
20 var id = api.keys.sync.id()
21 var following = api.contact.obs.following(id)
22
23 var prepend = [
24 h('PageHeading', [
25 h('h1', [h('strong', 'Gatherings'), ' from your extended network']),
26 h('div.meta', [
27 h('button -add', {
28 'ev-click': createGathering
29 }, '+ Add Gathering')
30 ])
31 ])
32 ]
33
34 return api.feed.html.rollup(api.feed.pull.type('gathering'), {
35 prepend,
36 bumpFilter: function (msg) {
37 if (msg.value && msg.value.content && typeof msg.value.content === 'object') {
38 var author = msg.value.author
39 return id === author || following().has(author)
40 }
41 },
42 rootFilter: (msg) => msg.value.content.type === 'gathering',
43 updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.latest({ids: [id]}))
44 })
45 })
46
47 function createGathering () {
48 api.gathering.sheet.edit()
49 }
50}
51

Built with git-ssb-web