git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: e26da8bb43ee4322240170dc15fa3b89df6ee0fa

Files: e26da8bb43ee4322240170dc15fa3b89df6ee0fa / message / obs / backlinks.js

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

Built with git-ssb-web