git ssb

1+

Daan Patchwork / patchwork



Tree: 3451510316992d414ec76ba5b29681fe359b7428

Files: 3451510316992d414ec76ba5b29681fe359b7428 / lib / depject / message / html / forks.js

1103 bytesRaw
1const nest = require('depnest')
2const ref = require('ssb-ref')
3const { h, computed } = require('mutant')
4const many = require('../../../many')
5
6exports.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
15exports.gives = nest('message.html.forks')
16
17exports.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