aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bog.js91
-rw-r--r--render.js4
2 files changed, 52 insertions, 43 deletions
diff --git a/bog.js b/bog.js
index d8ee2a8..2170216 100644
--- a/bog.js
+++ b/bog.js
@@ -115,28 +115,20 @@ function getImage (id, keys, classList) {
var image = h('img', {classList: 'avatar'})
}
- localforage.getItem('image:' + id).then(cache => {
- //if (cache) {
- // return image.src = cache
- //} else {
- bog().then(log => {
- if (log) {
- for (var i = 0; i < log.length; i++) {
- if ((log[i].imaged === id) && (log[i].author === keys.publicKey)) {
- // if you've identified someone as something else show that something else
- localforage.setItem('image:' + id, log[i].image)
- image.src = cache
- return image.src = cache
- } else if ((log[i].imaged === id) && (log[i].author === id)) {
- // else if show the image they gave themselves
- localforage.setItem('image:' + id, log[i].image)
- image.src = cache
- return image.src = cache
- }
- }
+ bog().then(log => {
+ if (log) {
+ for (var i = 0; i < log.length; i++) {
+ if ((log[i].imaged === id) && (log[i].author === keys.publicKey)) {
+ // if you've identified someone as something else show that something else
+ localforage.setItem('image:' + id, log[i].image)
+ return image.src = log[i].image
+ } else if ((log[i].imaged === id) && (log[i].author === id)) {
+ // else if show the image they gave themselves
+ localforage.setItem('image:' + id, log[i].image)
+ return image.src = log[i].image
}
- })
- //}
+ }
+ }
})
return image
}
@@ -148,29 +140,46 @@ function getName (id, keys) {
name.textContent = id.substring(0, 10) + '...'
- localforage.getItem('name:' + id).then(cache => {
+ bog().then(log => {
+ if (log) {
+ for (var i = 0; i < log.length; i++ ) {
+ if ((log[i].named === id) && (log[i].author === keys.publicKey)) {
+ // if you've identified someone as something else show that something else
+ localforage.setItem('name:' + id, log[i].name)
+ return name.textContent = '@' + log[i].name
+ } else if ((log[i].named === id) && (log[i].author === id)) {
+ // else if show the name they gave themselves
+ localforage.setItem('name:' + id, log[i].name)
+ return name.textContent = '@' + log[i].name
+ }
+ // there should probably be some sort of sybil attack resiliance here (weight avatar name based on number of times used by individuals), but this will do for now.
+ }
+ }
+ })
+ return name
+}
+
+function getQuickImage (id, keys) {
+ var image = h('img', {classList: 'avatar'})
+
+ localforage.getItem('image:' + id).then(cache => {
if (cache) {
- //console.log(cache)
- return name.textContent = '@' + cache
- } else {
- bog().then(log => {
- if (log) {
- for (var i = 0; i < log.length; i++ ) {
- if ((log[i].named === id) && (log[i].author === keys.publicKey)) {
- // if you've identified someone as something else show that something else
- localforage.setItem('name:' + id, log[i].name)
- return name.textContent = '@' + log[i].name
- } else if ((log[i].named === id) && (log[i].author === id)) {
- // else if show the name they gave themselves
- localforage.setItem('name:' + id, log[i].name)
- return name.textContent = '@' + log[i].name
- }
- // there should probably be some sort of sybil attack resiliance here (weight avatar name based on number of times used by individuals), but this will do for now.
- }
- }
- })
+ image.src = cache
}
})
+
+ return image
+}
+
+function getQuickName (id, keys) {
+ var name = h('span', [id.substring(0, 10)])
+
+ localforage.getItem('name:' + id).then(cache => {
+ if (cache) {
+ name.textContent = '@' + cache
+ }
+ })
+
return name
}
diff --git a/render.js b/render.js
index 5ecbdda..326f02e 100644
--- a/render.js
+++ b/render.js
@@ -25,8 +25,8 @@ function getHeader (post, keys, mini) {
]),
h('p', [
h('a', {href: '#' + post.author}, [
- getImage(post.author, keys),
- getName(post.author, keys)
+ getQuickImage(post.author, keys),
+ getQuickName(post.author, keys)
]),
mini
])