Files: 2f8b5a42a327baeb86c4cc6af56c65848948d0ec / app / html / channelCard.js
1432 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, when } = require('mutant') |
3 | |
4 | |
5 | exports.gives = nest('app.html.channelCard') |
6 | |
7 | exports.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 | |
17 | exports.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