git ssb

2+

mixmix / ticktack



Tree: b54653fc52f7f7d05a4fc1e294bb6151561bff09

Files: b54653fc52f7f7d05a4fc1e294bb6151561bff09 / contact / obs / relationships.js

883 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
32

Built with git-ssb-web