git ssb

10+

Matt McKegg / patchwork



Tree: b0d0023156505d649f8c12faf827dd3d345a64d1

Files: b0d0023156505d649f8c12faf827dd3d345a64d1 / modules / page / html / render / channels.js

1190 bytesRaw
1var nest = require('depnest')
2var { h, when, computed, map } = require('mutant')
3
4exports.needs = nest({
5 'message.async.publish': 'first',
6 'keys.sync.id': 'first',
7 'channel.obs': {
8 subscribed: 'first',
9 recent: 'first'
10 },
11 'intl.sync.i18n': 'first'
12})
13
14exports.gives = nest('page.html.render')
15
16exports.create = function (api) {
17 return nest('page.html.render', function page (path) {
18 if (path !== '/channels') return
19
20 var id = api.keys.sync.id()
21 var channels = api.channel.obs.recent()
22 var subscribedChannels = api.channel.obs.subscribed(id)
23 var loading = computed(subscribedChannels.sync, x => !x)
24
25 return h('div', { classList: 'Scroller' }, [
26 when(loading, [ h('Loading') ]),
27 h('div', {
28 classList: 'AllChannels',
29 hidden: loading
30 }, [
31 map(channels, (channel) => {
32 var subscribed = subscribedChannels.has(channel)
33 return h('a.channel', {
34 href: `#${channel}`,
35 classList: [
36 when(subscribed, '-subscribed')
37 ]
38 }, [
39 h('span.name', '#' + channel)
40 ])
41 }, {maxTime: 5, idle: true})
42 ])
43 ])
44 })
45}
46

Built with git-ssb-web