git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 07b744af8d044a6cc9f20deae76832329371760f

Files: 07b744af8d044a6cc9f20deae76832329371760f / 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