Files: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd / modules / message-link.js
533 bytesRaw
1 | var h = require('hyperscript') |
2 | var ref = require('ssb-ref') |
3 | |
4 | exports.needs = { |
5 | message_name: 'first' |
6 | } |
7 | |
8 | exports.gives = 'message_link' |
9 | |
10 | exports.create = function (api) { |
11 | |
12 | return function (id) { |
13 | |
14 | if('string' !== typeof id) |
15 | throw new Error('link must be to message id') |
16 | |
17 | var link = h('a', {href: '#'+id}, id.substring(0, 10)+'...') |
18 | |
19 | if(ref.isMsg(id)) |
20 | api.message_name(id, function (err, name) { |
21 | if(err) console.error(err) |
22 | else link.textContent = name |
23 | }) |
24 | |
25 | return link |
26 | } |
27 | } |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 |
Built with git-ssb-web