Files: 51182f00266ed98dce8a438372451c49940eaa36 / message / html / channel.js
760 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, resolve } = require('mutant') |
3 | |
4 | exports.gives = nest('message.html.channel') |
5 | |
6 | exports.needs = nest({ |
7 | 'history.sync.push': 'first' |
8 | }) |
9 | |
10 | exports.create = function (api) { |
11 | return nest('message.html.channel', channel) |
12 | |
13 | function channel (msgOrChannel, opts = {} ) { |
14 | const channel = typeof msgOrChannel === 'string' |
15 | ? msgOrChannel |
16 | : msgOrChannel.value.content.channel |
17 | |
18 | if (!channel) return |
19 | |
20 | const { |
21 | classList = [], |
22 | location = { page: 'blogSearch', channel } |
23 | } = opts |
24 | |
25 | const goToChannel = (e) => { |
26 | e.stopPropagation() |
27 | |
28 | api.history.sync.push(location) |
29 | } |
30 | |
31 | return h('Button -channel', { |
32 | 'ev-click': goToChannel, |
33 | classList |
34 | }, channel) |
35 | } |
36 | } |
37 | |
38 | |
39 |
Built with git-ssb-web