git ssb

2+

mixmix / ticktack



Tree: 74c2a9875f6869e3cc0b3448d52f059aff9a2bfb

Files: 74c2a9875f6869e3cc0b3448d52f059aff9a2bfb / 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