git ssb

10+

Matt McKegg / patchwork



Tree: ee9f43c70d668ebeffd5077be5daae16dd4f47b4

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

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

Built with git-ssb-web