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