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