git ssb

2+

mixmix / ticktack



Tree: c2cb876f7ef9db11df921ff5cebd31e0d8721cd1

Files: c2cb876f7ef9db11df921ff5cebd31e0d8721cd1 / channel / obs.js

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

Built with git-ssb-web