Files: 5da29345498ec8655898194cf2ab904e54398e37 / modules / page / html / render / channels.js
1190 bytesRaw
1 | var nest = require('depnest') |
2 | var { h, when, computed, map } = require('mutant') |
3 | |
4 | exports.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 | |
14 | exports.gives = nest('page.html.render') |
15 | |
16 | exports.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