Files: 3451510316992d414ec76ba5b29681fe359b7428 / lib / depject / message / html / forks.js
1103 bytesRaw
1 | const nest = require('depnest') |
2 | const ref = require('ssb-ref') |
3 | const { h, computed } = require('mutant') |
4 | const many = require('../../../many') |
5 | |
6 | exports.needs = nest({ |
7 | 'backlinks.obs.forks': 'first', |
8 | 'message.obs': { |
9 | name: 'first' |
10 | }, |
11 | 'profile.html.person': 'first', |
12 | 'intl.sync.i18n': 'first' |
13 | }) |
14 | |
15 | exports.gives = nest('message.html.forks') |
16 | |
17 | exports.create = function (api) { |
18 | const i18n = api.intl.sync.i18n |
19 | return nest('message.html.forks', function (msg) { |
20 | if (!ref.type(msg.key)) return [] |
21 | |
22 | const forks = api.backlinks.obs.forks(msg) |
23 | |
24 | return [ |
25 | computed(forks, links => { |
26 | if (links && links.length) { |
27 | const authors = new Set(links.map(link => link.author)) |
28 | return h('a.backlink', { |
29 | href: msg.key, |
30 | anchor: links[0].id |
31 | }, [ |
32 | h('strong', [ |
33 | many(authors, api.profile.html.person, i18n), i18n(' forked this discussion:') |
34 | ]), ' ', |
35 | api.message.obs.name(links[0].id), |
36 | ' (', links.length, ')' |
37 | ]) |
38 | } |
39 | }, { idle: true }) |
40 | ] |
41 | }) |
42 | } |
43 |
Built with git-ssb-web