Files: ca44a0a40e4d24c2b6b42467fac6072170073817 / channel / html / subscribe.js
903 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 | 'app.obs.pluginsOk': 'first', |
8 | 'translations.sync.strings': 'first', |
9 | 'channel.obs.isSubscribedTo': 'first', |
10 | 'channel.async.subscribe': 'first', |
11 | 'channel.async.unsubscribe': 'first' |
12 | }) |
13 | |
14 | exports.create = function (api) { |
15 | return nest('channel.html.subscribe', (channel) => { |
16 | channel = channel.replace(/^#/, '') |
17 | const strings = api.translations.sync.strings() |
18 | const { subscribe, unsubscribe } = api.channel.async |
19 | |
20 | return when(api.app.obs.pluginsOk(), |
21 | when(api.channel.obs.isSubscribedTo(channel), |
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