git ssb

2+

mixmix / ticktack



Tree: bafe2257bf02da68e34787b3fc33ece99031fb10

Files: bafe2257bf02da68e34787b3fc33ece99031fb10 / channel / html / subscribe.js

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

Built with git-ssb-web