git ssb

2+

mixmix / ticktack



Tree: 9b7b6df024c1c91b5fa96dbbe3c3cbf1e5000f18

Files: 9b7b6df024c1c91b5fa96dbbe3c3cbf1e5000f18 / app / html / channelCard.js

1968 bytesRaw
1var nest = require('depnest')
2const { h, map, when, Value } = require('mutant')
3var isString= require('lodash/isString')
4var maxBy= require('lodash/maxBy')
5var markdown = require('ssb-markdown')
6var ref = require('ssb-ref')
7var htmlEscape = require('html-escape')
8
9exports.gives = nest('app.html.channelCard')
10
11exports.needs = nest({
12 'keys.sync.id': 'first',
13 'history.sync.push': 'first',
14 'translations.sync.strings': 'first',
15 'channel.obs.subscribed': 'first',
16 'channel.async.subscribe': 'first',
17 'channel.async.unsubscribe': 'first',
18 'channel.sync.isSubscribedTo': 'first',
19})
20
21exports.create = function (api) {
22
23 return nest('app.html.channelCard', (channel) => {
24 var strings = api.translations.sync.strings()
25
26 const myId = api.keys.sync.id()
27 const { subscribed } = api.channel.obs
28 const { subscribe, unsubscribe } = api.channel.async
29 const { isSubscribedTo } = api.channel.sync
30 const myChannels = subscribed(myId)
31 let cs = myChannels().values()
32 const youSubscribe = Value(isSubscribedTo(channel, myId))
33
34 let cb = () => {
35 youSubscribe.set(isSubscribedTo(channel, myId))
36 }
37
38 const goToChannel = (e, channel) => {
39 e.stopPropagation()
40
41 api.history.sync.push({ page: 'channelShow', channel: channel })
42 }
43
44 var b = h('ChannelCard', [
45 h('div.content', [
46 h('div.text', [
47 h('h2', {'ev-click': ev => goToChannel(ev, channel)}, channel),
48 when(youSubscribe,
49 h('Button', { 'ev-click': () => unsubscribe(channel, cb) }, strings.channelShow.action.unsubscribe),
50 h('Button', { 'ev-click': () => subscribe(channel, cb) }, strings.channelShow.action.subscribe)
51 ),
52 ])
53 ])
54 ])
55
56 return b
57 })
58}
59
60

Built with git-ssb-web