Files: 59d3d0d716da753cf2d23af1ad3fab75bfc9dc93 / modules / page / html / render / gatherings.js
1481 bytesRaw
1 | var { h } = require('mutant') |
2 | var nest = require('depnest') |
3 | |
4 | exports.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 | |
15 | exports.gives = nest('page.html.render') |
16 | |
17 | exports.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