git ssb

16+

Dominic / patchbay



Tree: 2d581d5e26ada49ca088f855fb0c84c4a6f129c6

Files: 2d581d5e26ada49ca088f855fb0c84c4a6f129c6 / modules_basic / avatar / name.js

772 bytesRaw
1var h = require('hyperscript')
2
3exports.needs = {
4 signifier: 'first'
5}
6
7exports.gives = 'avatar_name'
8
9exports.create = function (api) {
10
11 return function name (id) {
12
13 if('string' !== typeof id)
14 throw new Error('avatar id must be a string')
15
16 var n = h('span', id ? id.substring(0, 10) : JSON.stringify(id))
17
18 //choose the most popular name for this person.
19 //for anything like this you'll see I have used sbot.links2
20 //which is the ssb-links plugin. as you'll see the query interface
21 //is pretty powerful!
22 //TODO: "most popular" name is easily gameable.
23 //must come up with something better than this.
24
25 api.signifier(id, function (_, names) {
26 if(names.length) n.textContent = names[0].name
27 })
28
29 return n
30 }
31
32}
33
34
35
36

Built with git-ssb-web