git ssb

2+

ev / mvd



Commit 75aa0a40a0fa419a086ebf278da73cf1ddd88135

use cached avatar, and then check for new avatars to replace cached avatar

Ev Bogue committed on 6/6/2018, 5:38:38 PM
Parent: 6d20a46e7abaa94845f87c72e3d6c8a135b098a2

Files changed

avatar.jschanged
avatar.jsView
@@ -6,30 +6,35 @@
66 var config = require('./config')()
77
88 module.exports.name = function (id) {
99
10- var name = h('span', id.substring(0, 10))
11- if (localStorage[id + 'name'])
12- name.textContent = localStorage[id + 'name']
13- else
10 + function getName (id) {
1411 pull(query({query: [{$filter: { value: { author: id, content: {type: 'about', about: id, name: {'$truthy': true}}}}}], reverse: true}),
1512 pull.collect(function (err, data){
1613 if(data[0]) {
1714 localStorage[id + 'name'] = '@' + data[0].value.content.name
1815 name.textContent = localStorage[id + 'name']
1916 }
2017 }))
18 + }
19 +
20 + var name = h('span', id.substring(0, 10))
21 +
22 + if (localStorage[id + 'name']) {
23 + name.textContent = localStorage[id + 'name']
24 + getName(id)
25 + }
26 + else {
27 + getName(id)
28 + }
29 +
2130 return name
2231 }
2332
2433 var ref = require('ssb-ref')
2534
2635 module.exports.image = function (id) {
27- var img = visualize(new Buffer(id.substring(1), 'base64'), 256)
28-
29- if (localStorage[id + 'image'])
30- img.src = localStorage[id + 'image']
31- else
36 + function getImage (id) {
3237 pull(query({query: [{$filter: { value: { author: id, content: {type: 'about', about: id, image: {'$truthy': true}}}}}], reverse: true}),
3338 pull.collect(function (err, data){
3439 if(data[0]) {
3540 if (ref.isBlob(data[0].value.content.image.link)) {
@@ -43,8 +48,17 @@
4348 }
4449 }
4550 })
4651 )
52 + }
4753
54 + var img = visualize(new Buffer(id.substring(1), 'base64'), 256)
55 +
56 + if (localStorage[id + 'image']) {
57 + img.src = localStorage[id + 'image']
58 + getImage(id)
59 + } else {
60 + getImage(id)
61 + }
4862 return img
4963 }
5064

Built with git-ssb-web