git ssb

1+

Daan Patchwork / patchwork



Tree: b6d7ee34ab7b57861dd88fc633ba98bfb721b099

Files: b6d7ee34ab7b57861dd88fc633ba98bfb721b099 / lib / depject / message / html / forks.js

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

Built with git-ssb-web