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