git ssb

2+

mixmix / ticktack



Tree: d0ffcb2afd083ec1a77409a74c50f7064993f28a

Files: d0ffcb2afd083ec1a77409a74c50f7064993f28a / channel / sync.js

571 bytesRaw
1var nest = require('depnest')
2var ref = require('ssb-ref')
3
4exports.needs = nest({
5 'keys.sync.id': 'first',
6 'channel.obs.subscribed': 'first',
7})
8
9exports.gives = nest('channel.sync.isSubscribedTo')
10
11exports.create = function (api) {
12 return nest('channel.sync.isSubscribedTo', isSubscribedTo)
13
14 function isSubscribedTo (channel, id) {
15 if (!ref.isFeed(id)) {
16 id = api.keys.sync.id()
17 }
18
19 const { subscribed } = api.channel.obs
20 const myChannels = subscribed(id)
21 let v = myChannels().values()
22 return [...v].includes(channel)
23 }
24}
25

Built with git-ssb-web