git ssb

2+

mixmix / ticktack



Tree: 26ec4bc385c250f6b9b1d0eb534ceaff0f876083

Files: 26ec4bc385c250f6b9b1d0eb534ceaff0f876083 / contact / obs / relationships.js

881 bytesRaw
1const nest = require('depnest')
2const { h, map, computed, when } = require('mutant')
3const { intersection, difference } = require('lodash')
4
5exports.gives = nest('contact.obs.relationships')
6
7exports.needs = nest({
8 'contact.obs.followers': 'first',
9 'contact.obs.following': 'first',
10 'keys.sync.id': 'first'
11})
12
13exports.create = function (api) {
14 return nest({
15 'contact.obs.relationships': relationships
16 })
17
18 function relationships (id) {
19 var following = api.contact.obs.following(id)
20 var followers = api.contact.obs.followers(id)
21
22 return computed([following, followers], (followingRaw, followersRaw) => {
23 const friends = intersection([...followingRaw], [...followersRaw])
24 const followers = difference(followersRaw, friends)
25 const following = difference(followingRaw, friends)
26
27 return { friends, followers, following }
28 })
29 }
30}
31

Built with git-ssb-web