Files: e69a4bdedf11f26f5a8b25434154fefafbf6ba2a / message / html / link.js
609 bytesRaw
1 | var h = require('mutant/h') |
2 | var ref = require('ssb-ref') |
3 | var nest = require('depnest') |
4 | |
5 | exports.needs = nest('message.async.name', 'first') |
6 | |
7 | exports.gives = nest('message.html.link') |
8 | |
9 | exports.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