git ssb

16+

Dominic / patchbay



Commit db8e0ddb7b72722a29b8f828604b39ed1f4ea0ed

finally fix profile avatar addition

mixmix committed on 10/21/2018, 1:32:32 PM
Parent: b2b759194681277e1a71a569b3c356f1a3c97344

Files changed

about/html/edit.jschanged
about/html/edit.jsView
@@ -1,9 +1,8 @@
11 const nest = require('depnest')
22 const dataurl = require('dataurl-')
33 const hyperfile = require('hyperfile')
44 const hypercrop = require('hypercrop')
5-const hyperlightbox = require('hyperlightbox')
65 const {
76 h, Value, Dict, Struct,
87 map, computed, when, dictToCollection, onceTrue
98 } = require('mutant')
@@ -19,8 +18,9 @@
1918 description: 'first',
2019 latestValue: 'first',
2120 groupedValues: 'first'
2221 },
22 + 'app.html.modal': 'first',
2323 'blob.sync.url': 'first',
2424 'keys.sync.id': 'first',
2525 'message.html.confirm': 'first',
2626 'message.html.markdown': 'first',
@@ -73,10 +73,8 @@
7373 current: api.about.obs.latestValue(id, 'publicWebHosting'),
7474 new: Value(api.about.obs.latestValue(id, 'publicWebHosting')())
7575 })
7676
77- var lightbox = hyperlightbox()
78-
7977 var isPossibleUpdate = computed([name.new, avatar.new, publicWebHosting.new], (name, avatar, publicWebHostingValue) => {
8078 return name || avatar.link || (isMe && publicWebHostingValue !== publicWebHosting.current())
8179 })
8280
@@ -101,10 +99,14 @@
10199 balances.set(data)
102100 })
103101 })
104102
103 + const modalContent = Value()
104 + const isOpen = Value(false)
105 + const modal = api.app.html.modal(modalContent, { isOpen })
106 +
105107 return h('AboutEditor', [
106- lightbox,
108 + modal,
107109 h('section.avatar', [
108110 h('section', [
109111 h('img', { src: avatarSrc })
110112 ]),
@@ -161,11 +163,11 @@
161163 ])
162164 ])
163165
164166 function dataUrlCallback (data) {
165- const cropCallback = (err, cropData) => {
167 + const cropEl = Crop(data, (err, cropData) => {
166168 if (err) throw err
167- if (!cropData) return lightbox.close()
169 + if (!cropData) return isOpen.set(false)
168170
169171 var _data = dataurl.parse(cropData)
170172 api.sbot.async.addBlob(pull.once(_data.data), (err, hash) => {
171173 if (err) throw err // TODO check if this is safely caught by error catcher
@@ -177,19 +179,19 @@
177179 width: 512,
178180 height: 512
179181 })
180182 })
181- lightbox.close()
182- }
183 + isOpen.set(false)
184 + })
183185
184- const cropEl = Crop(data, cropCallback)
185- lightbox.show(cropEl)
186 + modalContent.set(cropEl)
187 + isOpen.set(true)
186188 }
187189
188190 function Crop (data, cb) {
189- var img = h('img', {src: data})
191 + var img = h('img', { src: data })
190192
191- var crop = h('div')
193 + var crop = Value()
192194
193195 waitForImg()
194196
195197 return h('div.cropper', [
@@ -205,9 +207,9 @@
205207 return window.setTimeout(waitForImg, 100)
206208 }
207209
208210 var canvas = hypercrop(img)
209- crop = (
211 + crop.set(
210212 h('PatchProfileCrop', [
211213 h('header', 'click and drag to crop your image'),
212214 canvas,
213215 h('section.actions', [

Built with git-ssb-web