Commit 8261134eb7daa7f16ad7f83ebb1549e60b37b70d
add obs_about_image_url
Matt McKegg committed on 2/13/2017, 9:31:42 AMParent: b58dd46b8f88f0917c480faf8286bdd209933739
Files changed
observables/about.js | changed |
observables/about.js | ||
---|---|---|
@@ -1,22 +1,33 @@ | ||
1 | -var {Value, Struct} = require('mutant') | |
1 … | +var {Value, Struct, computed} = require('mutant') | |
2 | 2 … | var Abortable = require('pull-abortable') |
3 | 3 … | var pull = require('pull-stream') |
4 … | +var msgs = require('ssb-msgs') | |
4 | 5 … | |
5 | 6 … | exports.needs = { |
6 | - sbot_user_feed: 'first' | |
7 … | + sbot_user_feed: 'first', | |
8 … | + blob_url: 'first' | |
7 | 9 … | } |
8 | 10 … | exports.gives = { |
9 | 11 … | obs_about_name: true, |
10 | - obs_about_image: true | |
12 … | + obs_about_image: true, | |
13 … | + obs_about_image_url: true | |
11 | 14 … | } |
12 | 15 … | |
13 | 16 … | exports.create = function (api) { |
14 | 17 … | var cache = {} |
15 | 18 … | |
16 | 19 … | return { |
17 | 20 … | obs_about_name: (id) => get(id).displayName, |
18 | - obs_about_image: (id) => get(id).image | |
21 … | + obs_about_image: (id) => get(id).image, | |
22 … | + obs_about_image_url: (id) => { | |
23 … | + return computed(get(id).image, (image) => { | |
24 … | + var obj = msgs.link(image, 'blob') | |
25 … | + if (obj) { | |
26 … | + return api.blob_url(obj.link) | |
27 … | + } | |
28 … | + }) | |
29 … | + } | |
19 | 30 … | } |
20 | 31 … | |
21 | 32 … | function get (id) { |
22 | 33 … | if (!cache[id]) { |
Built with git-ssb-web