git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 217c274425bfc6f97a221190b58a329730ab0482

Files: 217c274425bfc6f97a221190b58a329730ab0482 / modules / page / html / render / mentions.js

976 bytesRaw
1var nest = require('depnest')
2
3exports.needs = nest({
4 'feed.html.rollup': 'first',
5 'keys.sync.id': 'first',
6 'feed.pull.mentions': 'first'
7})
8
9exports.gives = nest('page.html.render')
10
11exports.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 (Array.isArray(msg.value.content.mentions) && msg.value.content.mentions.some(mention => {
24 return mention && mention.link === id
25 })) {
26 return 'mention'
27 } else if (msg.value.content.type === 'contact') {
28 return true
29 } else if (msg.value.content.type === 'about') {
30 return true
31 }
32 }
33 })
34}
35

Built with git-ssb-web