git ssb

2+

mixmix / ticktack



Commit b0b8e31176b8cf099174eeaa8faf5e129916374e

fix profile edit callback from settings

mix irving committed on 8/27/2017, 11:24:45 PM
Parent: ee8e72469e3082880b91e42e3ed64747ad35033f

Files changed

app/html/header.jschanged
app/page/settings.jschanged
app/page/settings.mcsschanged
app/page/userEdit.jschanged
app/html/header.jsView
@@ -16,9 +16,9 @@
1616 // FUTURE breadcrumb here ?
1717 // h('h1', computed(nav.location, e => e.element.title)),
1818
1919 h('div.tools', [
20- h('i.fa.fa-user', { 'ev-click': () => nav.push({page:'userEdit', feed: api.keys.sync.id()}) }), // TEMP
20+ // h('i.fa.fa-user', { 'ev-click': () => nav.push({page:'userEdit', feed: api.keys.sync.id()}) }), // TEMP
2121 h('i.fa.fa-address-book', { 'ev-click': () => nav.push({page:'userFind'}) }),
2222 h('i.fa.fa-hashtag', { 'ev-click': () => nav.push({page:'groupFind'}) }),
2323 h('i.fa.fa-gear', { 'ev-click': () => nav.push({page:'settings'}) })
2424 ])
app/page/settings.jsView
@@ -31,8 +31,17 @@
3131 const feed = api.keys.sync.id()
3232 const strings = api.translations.sync.strings()
3333 const currentLanguage = api.settings.sync.get('language')
3434
35+ const handleEdit = () => api.history.sync.push({
36+ page:'userEdit',
37+ feed,
38+ callback: (err, didEdit) => {
39+ if (err) throw new Error ('Error editing profile', err)
40+ api.history.sync.push({ page: 'settings' })
41+ }
42+ })
43+
3544 return h('Page -settings', [
3645 h('div.container', [
3746 h('h1', strings.settingsPage.title),
3847 h('section -profile', [
@@ -41,9 +50,9 @@
4150 h('div.name', api.about.obs.name(feed)),
4251 api.about.html.image(feed),
4352 ]),
4453 h('div.actions', [
45- h('Button', { 'ev-click': () => api.history.sync.push({page:'userEdit', feed}) }, [
54+ h('Button', { 'ev-click': handleEdit}, [
4655 strings.settingsPage.action.edit,
4756 h('i.fa.fa-pencil')
4857 ])
4958 ])
app/page/settings.mcssView
@@ -5,8 +5,12 @@
55 background: #fff
66 padding: 1rem
77 $maxWidthSmaller
88
9+ h1 {
10+ margin-top: 0
11+ }
12+
913 section {
1014 padding-bottom: 2rem
1115 margin-bottom: 2rem
1216
app/page/userEdit.jsView
@@ -12,10 +12,10 @@
1212 exports.create = (api) => {
1313 return nest('app.page.userEdit', userEdit)
1414
1515 function userEdit (location) {
16- // location is an object { feed, page: 'userEdit' }
17- const { feed } = location
16+ // location is an object { feed, page: 'userEdit', callback }
17+ var { feed, callback } = location
1818
1919 const strings = api.translations.sync.strings()
2020
2121 const options = Object.assign({}, location, {
@@ -29,13 +29,16 @@
2929 save: strings.userEdit.action.save,
3030 }
3131 })
3232
33- const callback = (err, didEdit) => {
33+ const defaultCallback = (err, didEdit) => {
3434 if (err) throw new Error ('Error editing profile', err)
3535
3636 api.history.sync.push({ page: 'userShow', feed })
3737 }
38+ callback = typeof callback == 'function'
39+ ? callback
40+ : defaultCallback
3841
3942 return h('Page -userEdit', {}, [
4043 h('div.container', [
4144 api.about.page.edit(options, callback)

Built with git-ssb-web