Files: bafe2257bf02da68e34787b3fc33ece99031fb10 / channel / html / subscribe.js
861 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, when } = require('mutant') |
3 | |
4 | exports.gives = nest('channel.html.subscribe') |
5 | |
6 | exports.needs = nest({ |
7 | 'translations.sync.strings': 'first', |
8 | 'channel.obs.isSubscribedTo': 'first', |
9 | 'channel.async.subscribe': 'first', |
10 | 'channel.async.unsubscribe': 'first' |
11 | }) |
12 | |
13 | exports.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