Files: 4ef31e43684a11333c8cc97d2919d6dd41895bd0 / message / html / channel.js
820 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 | var channel = typeof msgOrChannel === 'string' |
15 | ? msgOrChannel |
16 | : msgOrChannel.value.content.channel |
17 | if (!channel) return |
18 | |
19 | channel = channel.replace(/^#/, '') |
20 | if (!channel) return |
21 | |
22 | const { |
23 | classList = [], |
24 | location = { page: 'channelShow', channel } |
25 | } = opts |
26 | |
27 | const goToChannel = (e) => { |
28 | e.stopPropagation() |
29 | |
30 | api.history.sync.push(location) |
31 | } |
32 | |
33 | return h('Button -channel', { |
34 | 'ev-click': goToChannel, |
35 | classList |
36 | }, channel) |
37 | } |
38 | } |
39 |
Built with git-ssb-web