Files: 77e7fa628b43035fa4c24ea1a9eb35529874721d / modules / page / html / render / mentions.js
809 bytesRaw
1 | var { h, when } = require('mutant') |
2 | var nest = require('depnest') |
3 | |
4 | exports.needs = nest({ |
5 | 'feed.html.rollup': 'first', |
6 | 'keys.sync.id': 'first', |
7 | 'feed.pull.mentions': 'first' |
8 | }) |
9 | |
10 | exports.gives = nest('page.html.render') |
11 | |
12 | exports.create = function (api) { |
13 | return nest('page.html.render', function mentions (path) { |
14 | if (path !== '/mentions') return |
15 | var id = api.keys.sync.id() |
16 | return api.feed.html.rollup(api.feed.pull.mentions(id), { |
17 | bumpFilter: mentionFilter, |
18 | displayFilter: mentionFilter |
19 | }) |
20 | |
21 | // scoped |
22 | function mentionFilter (msg) { |
23 | if (Array.isArray(msg.value.content.mentions)) { |
24 | if (msg.value.content.mentions.some(mention => { |
25 | return mention && mention.link === id |
26 | })) { |
27 | return 'mention' |
28 | } |
29 | } |
30 | } |
31 | }) |
32 | } |
33 |
Built with git-ssb-web