Files: f84a9667fa03b5fc5f43b038c6e7616276a5907a / 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