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