git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 5a28f5df1543b0e5813e5fe7dbc74f2ec907ff5a

Files: 5a28f5df1543b0e5813e5fe7dbc74f2ec907ff5a / message / obs / backlinks.js

868 bytesRaw
1var nest = require('depnest')
2var computed = require('mutant/computed')
3
4exports.needs = nest({
5 'backlinks.obs.for': 'first',
6 'message.sync.root': 'first'
7})
8
9exports.gives = nest('message.obs.backlinks', true)
10
11exports.create = function (api) {
12 return nest({
13 // DEPRECATED: should use backlinks.obs.for
14 'message.obs.backlinks': (id) => backlinks(id)
15 })
16
17 function backlinks (id) {
18 return computed([api.backlinks.obs.for(id)], (msgs) => {
19 return msgs.map(map).filter((backlink) => {
20 return backlink.type !== 'vote' && backlink.type !== 'about'
21 })
22 })
23 }
24
25 function map (msg) {
26 return {
27 dest: msg.dest,
28 id: msg.key,
29 timestamp: msg.timestamp,
30 type: msg.value.content.type,
31 root: api.message.sync.root(msg),
32 branch: msg.value.content.branch,
33 author: msg.value.author
34 }
35 }
36}
37

Built with git-ssb-web