git ssb

2+

mixmix / ticktack



Tree: 202db7a1462af5a1b1dbeb6b5c220468060f96ea

Files: 202db7a1462af5a1b1dbeb6b5c220468060f96ea / channel / html / subscribe.js

863 bytesRaw
1const nest = require('depnest')
2const { h, when } = require('mutant')
3
4exports.gives = nest('channel.html.subscribe')
5
6exports.needs = nest({
7 'keys.sync.id': 'first',
8 'translations.sync.strings': 'first',
9 'channel.obs.isSubscribedTo': 'first',
10 'channel.async.subscribe': 'first',
11 'channel.async.unsubscribe': 'first',
12})
13
14exports.create = function (api) {
15
16 return nest('channel.html.subscribe', (channel) => {
17 const strings = api.translations.sync.strings()
18 const myId = api.keys.sync.id()
19 const { subscribe, unsubscribe } = api.channel.async
20
21 return when(api.channel.obs.isSubscribedTo(channel, myId),
22 h('Button', { 'ev-click': () => unsubscribe(channel) }, strings.channelShow.action.unsubscribe),
23 h('Button -primary', { 'ev-click': () => subscribe(channel) }, strings.channelShow.action.subscribe)
24 )
25 })
26}
27
28

Built with git-ssb-web