git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: e69a4bdedf11f26f5a8b25434154fefafbf6ba2a

Files: e69a4bdedf11f26f5a8b25434154fefafbf6ba2a / message / html / link.js

609 bytesRaw
1var h = require('mutant/h')
2var ref = require('ssb-ref')
3var nest = require('depnest')
4
5exports.needs = nest('message.async.name', 'first')
6
7exports.gives = nest('message.html.link')
8
9exports.create = function (api) {
10 return nest('message.html.link', function (id) {
11 if (typeof id !== 'string') { throw new Error('link must be to message id') }
12
13 var link = h('a', {href: id}, id.substring(0, 10) + '...')
14
15 if (ref.isMsg(id)) {
16 api.message.async.name(id, function (err, name) {
17 if (err) console.error(err)
18 else link.textContent = name
19 })
20 }
21
22 return link
23 })
24}
25

Built with git-ssb-web