Files: 3451510316992d414ec76ba5b29681fe359b7428 / lib / depject / page / html / render / mentions.js
940 bytesRaw
1 | const nest = require('depnest') |
2 | |
3 | exports.needs = nest({ |
4 | 'feed.html.rollup': 'first', |
5 | 'keys.sync.id': 'first', |
6 | 'sbot.pull.resumeStream': 'first', |
7 | 'sbot.pull.stream': '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 | |
16 | const getStream = api.sbot.pull.resumeStream((sbot, opts) => { |
17 | return sbot.patchwork.mentionsFeed.roots(opts) |
18 | }, { limit: 40, reverse: true }) |
19 | |
20 | return api.feed.html.rollup(getStream, { |
21 | compactFilter, // compact context messages |
22 | updateStream: api.sbot.pull.stream(sbot => sbot.patchwork.mentionsFeed.latest()) |
23 | }) |
24 | }) |
25 | |
26 | function compactFilter (msg) { |
27 | const id = api.keys.sync.id() |
28 | return !(Array.isArray(msg.value.content.mentions) && msg.value.content.mentions.some(mention => { |
29 | return mention && mention.link === id |
30 | })) |
31 | } |
32 | } |
33 |
Built with git-ssb-web