git ssb

2+

mixmix / ticktack



Tree: ff6e4fcbd2dfe0555d24afd3af1349fdbf313835

Files: ff6e4fcbd2dfe0555d24afd3af1349fdbf313835 / app / html / channelCard.js

1432 bytesRaw
1const nest = require('depnest')
2const { h, when } = require('mutant')
3
4
5exports.gives = nest('app.html.channelCard')
6
7exports.needs = nest({
8 'keys.sync.id': 'first',
9 'history.sync.push': 'first',
10 'translations.sync.strings': 'first',
11 'channel.obs.subscribed': 'first',
12 'channel.async.subscribe': 'first',
13 'channel.async.unsubscribe': 'first',
14 'channel.obs.isSubscribedTo': 'first',
15})
16
17exports.create = function (api) {
18
19 return nest('app.html.channelCard', (channel) => {
20 const strings = api.translations.sync.strings()
21 const myId = api.keys.sync.id()
22 const { subscribe, unsubscribe } = api.channel.async
23 const { isSubscribedTo } = api.channel.obs
24 const youSubscribe = isSubscribedTo(channel, myId)
25
26 const goToChannel = () => {
27 api.history.sync.push({ page: 'channelShow', channel: channel })
28 }
29
30 return h('ChannelCard', [
31 h('div.content', [
32 h('div.text', [
33 h('h2', {'ev-click': goToChannel}, channel),
34 when(youSubscribe,
35 h('Button', { 'ev-click': () => unsubscribe(channel) }, strings.channelShow.action.unsubscribe),
36 h('Button', { 'ev-click': () => subscribe(channel) }, strings.channelShow.action.subscribe)
37 ),
38 ])
39 ])
40 ])
41 })
42}
43
44

Built with git-ssb-web