aboutsummaryrefslogtreecommitdiff
path: root/bog.js
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2019-11-16 16:44:32 -0600
committerJoop Kiefte <ikojba@gmail.com>2019-11-17 02:37:07 +0100
commit86f284e9b1e5d13b9a0b17617f5bcc40c77b93cc (patch)
treed14b227bb262f3fee5210533bc5f8216283e23e3 /bog.js
parentf4feab4ca28cc5136ae00cd9a85681a95848bdd8 (diff)
add profile photos that are cropped to 250 by 250 and saved to your log
Diffstat (limited to 'bog.js')
-rw-r--r--bog.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/bog.js b/bog.js
index 6e6df7c..1aff354 100644
--- a/bog.js
+++ b/bog.js
@@ -96,6 +96,40 @@ async function get (key) {
}
}
+// bog.getImage
+
+function getImage (id, keys) {
+ var image = h('img', {classList: 'avatar'})
+
+ localforage.getItem('image:' + id).then(cache => {
+ if (cache) {
+ console.log('GOT IMAGE FROM CACHE: ' + 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)
+ console.log('FINDING IMAGE AND SAVING TO CACHE: ' + 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)
+ console.log('FINDING IMAGE AND SAVING TO CACHE: ' + log[i].image)
+ image.src = cache
+ return image.src = cache
+ }
+ }
+ }
+ })
+ }
+ })
+ return image
+}
+
// bog.getName -- iterates over a feed and returns a person's name
function getName (id, keys) {
@@ -129,7 +163,6 @@ function getName (id, keys) {
}
})
return name
-
}
// bog.regenerate -- regenerates main log by taking all of the feed logs, combinging them, and then sorting them