Commit 6e80a5dbc23e3ffb51c1f23aa7d8d8dbd9210393
profile refactor to use new about.obs.images
mix irving committed on 7/16/2017, 6:34:20 AMParent: 75e7d09a4f53e09195dca52ad820da44d54eaa93
Files changed
about/html/edit.js | changed |
about/html/edit.js | ||
---|---|---|
@@ -16,8 +16,9 @@ | ||
16 | 16 … | name: 'first', |
17 | 17 … | imageUrl: 'first', |
18 | 18 … | description: 'first' |
19 | 19 … | }, |
20 … | + 'about.obs.groupedValues': 'first', | |
20 | 21 … | 'blob.sync.url': 'first', |
21 | 22 … | 'keys.sync.id': 'first', |
22 | 23 … | 'message.html.confirm': 'first', |
23 | 24 … | 'message.html.markdown': 'first', |
@@ -45,17 +46,9 @@ | ||
45 | 46 … | current: api.about.obs.name(id), |
46 | 47 … | new: Value() |
47 | 48 … | }) |
48 | 49 … | |
49 | - // TODO use patchcores observable images + names | |
50 | - var images = MutantArray() | |
51 | - pull( | |
52 | - links({dest: id, rel: 'about', values: true}), | |
53 | - pull.map(e => e.value.content.image), | |
54 | - pull.filter(e => e && typeof e.link === 'string'), | |
55 | - pull.unique('link'), | |
56 | - pull.drain(image => images.push(image)) | |
57 | - ) | |
50 … | + const images = computed(api.about.obs.groupedValues(id, 'image'), Object.keys) | |
58 | 51 … | |
59 | 52 … | var namesRecord = MutantObject() |
60 | 53 … | // TODO constrain query to one name per peer? |
61 | 54 … | pull( |
@@ -76,9 +69,9 @@ | ||
76 | 69 … | }) |
77 | 70 … | |
78 | 71 … | var avatarSrc = computed([avatar], avatar => { |
79 | 72 … | if (avatar.new.link) return api.blob.sync.url(avatar.new.link) |
80 | - else return avatar.current | |
73 … | + return avatar.current | |
81 | 74 … | }) |
82 | 75 … | |
83 | 76 … | var displayedName = computed([name], name => { |
84 | 77 … | if (name.new) return name.new |
@@ -101,10 +94,10 @@ | ||
101 | 94 … | h('header', 'Aliases'), |
102 | 95 … | h('section.avatars', [ |
103 | 96 … | h('header', 'Avatars'), |
104 | 97 … | map(images, image => h('img', { |
105 | - 'src': api.blob.sync.url(image.link), | |
106 | - 'ev-click': () => avatar.new.set(image) | |
98 … | + 'src': api.blob.sync.url(image), | |
99 … | + 'ev-click': () => avatar.new.set({ link: image }) | |
107 | 100 … | })), |
108 | 101 … | h('div.file-upload', [ |
109 | 102 … | hyperfile.asDataURL(dataUrlCallback) |
110 | 103 … | ]) |
Built with git-ssb-web