git ssb

16+

Dominic / patchbay



Commit 307df129331fb2304b165db3702a5b8f05c84031

fix: add profile edit callback to update profile, clear selections

mix irving committed on 1/29/2017, 1:13:09 AM
Parent: e7d5a35db1a7f8894ba72038b284d13234c5d9c5

Files changed

modules_basic/avatar/edit.jschanged
modules_basic/message/confirm.jschanged
modules_basic/avatar/edit.jsView
@@ -75,8 +75,9 @@
7575 pull.drain(image => images.push(image) )
7676 )
7777
7878 var namesRecord = MutantObject()
79 + // TODO constrain query to one name per peer?
7980 pull(
8081 api.sbot_links({dest: id, rel: 'about', values: true}),
8182 pull.map(e => e.value.content.name),
8283 pull.filter(Boolean),
@@ -88,10 +89,10 @@
8889 var names = dictToCollection(namesRecord)
8990
9091 var lb = hyperlightbox()
9192
92-
93- var description = '' //TODO load this in, make this editable
93 + // TODO load this in, make this editable
94 + var description = ''
9495
9596 var isPossibleUpdate = computed([name.new, avatar.new], (name, avatar) => {
9697 return name || avatar.link
9798 })
@@ -140,9 +141,9 @@
140141 })
141142 ])
142143 ]),
143144 when(isPossibleUpdate, h('section.action', [
144- h('button.cancel', { 'ev-click': handleCancelClick }, 'cancel'),
145 + h('button.cancel', { 'ev-click': clearNewSelections }, 'cancel'),
145146 h('button.confirm', { 'ev-click': handleUpdateClick }, 'confirm changes')
146147 ]))
147148 ])
148149 ])
@@ -172,9 +173,9 @@
172173 })
173174 lb.show(el)
174175 }
175176
176- function handleCancelClick () {
177 + function clearNewSelections () {
177178 name.new.set(null)
178179 avatar.new.set({})
179180 }
180181
@@ -189,9 +190,18 @@
189190
190191 if (newName) msg.name = newName
191192 if (newAvatar.link) msg.image = newAvatar
192193
193- api.message_confirm(msg)
194 + api.message_confirm(msg, (err, data) => {
195 + if (err) return console.error(err)
196 +
197 + if (newName) name.original.set(newName)
198 + if (newAvatar) avatar.original.set(api.blob_url(newAvatar.link))
199 +
200 + clearNewSelections()
201 +
202 + // TODO - update aliases displayed
203 + })
194204 }
195205 }
196206
197207 }
modules_basic/message/confirm.jsView
@@ -39,22 +39,22 @@
3939 content: content
4040 }
4141 }
4242
43- var okay = h('button', {
43 + var okay = h('button.okay', {
4444 'ev-click': () => {
4545 lb.remove()
4646 api.publish(content, cb)
4747 }},
4848 'okay'
4949 )
5050
51- var cancel = h('button', {
51 + var cancel = h('button.cancel', {
5252 'ev-click': () => {
5353 lb.remove()
5454 cb(null)
5555 }},
56- 'Cancel'
56 + 'cancel'
5757 )
5858
5959 okay.addEventListener('keydown', function (ev) {
6060 if(ev.keyCode === 27) cancel.click() //escape
@@ -62,9 +62,9 @@
6262
6363 lb.show(h('MessageConfirm', [
6464 h('header -preview_description', h('h1', 'Preview')),
6565 h('section -message_preview', api.message_render(msg)),
66- h('section -actions', [okay, cancel])
66 + h('section -actions', [cancel, okay])
6767 ]
6868 ))
6969
7070 okay.focus()

Built with git-ssb-web