git ssb

0+

dangerousbeans / dangerous_patchbay



forked from Dominic / patchbay

Tree: 74fe7cba24a1be16ab96edeb828f80c1740bef44

Files: 74fe7cba24a1be16ab96edeb828f80c1740bef44 / modules_basic / message-link.js

674 bytesRaw
1var h = require('hyperscript')
2var 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
8exports.needs = {
9 message_name: 'first'
10}
11
12exports.gives = 'message_link'
13
14exports.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