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