git ssb

2+

mixmix / ticktack



Commit b51fde82e0d57c7264d7575dde85df093d30b696

ensure author avatar loads when ready

mix irving committed on 8/9/2017, 1:38:04 AM
Parent: 963223adf0b2978b4a3b94648b98620052008579

Files changed

app/html/app.jschanged
app/html/thread.jschanged
app/page/home.jschanged
app/page/private.jschanged
app/html/app.jsView
@@ -15,8 +15,7 @@
1515 function app () {
1616 const css = values(api.styles.css()).join('\n')
1717 insertCss(css)
1818
19- // return api.app.sync.goTo({ page: 'home' })
20- return api.app.sync.goTo({key: "%fXXZgQrwnj7F+Y19H0IXxNriuvPFoahvusih3UzpkfA=.sha256"})
19+ return api.app.sync.goTo({ page: 'home' })
2120 }
2221 }
app/html/thread.jsView
@@ -9,8 +9,9 @@
99 exports.needs = nest({
1010 'about.html.image': 'first',
1111 'app.sync.goTo': 'first',
1212 'feed.obs.thread': 'first',
13+ 'keys.sync.id': 'first',
1314 'message.html.markdown': 'first'
1415 })
1516
1617 exports.create = (api) => {
@@ -19,20 +20,19 @@
1920 function thread (id) {
2021 // location here can expected to be: { page: 'home' }
2122
2223
23- var myId = '@EMovhfIrFk4NihAKnRNhrfRaqIhBv1Wj8pTxJNgvCCY=.ed25519'
24- // TODO (mix) use keys.sync.id
24+ var myId = api.keys.sync.id()
2525
2626 const thread = api.feed.obs.thread(id)
2727 const chunkedMessages = buildChunkedMessages(thread.messages)
2828
2929 const { goTo } = api.app.sync
3030 const threadView = h('Thread',
3131 map(chunkedMessages, chunk => {
32- const author = get(chunk, '[0].value.author')
32+ const author = computed([chunk], chunk => get(chunk, '[0].value.author'))
3333
34- return author === myId
34+ return author() === myId
3535 ? h('div.my-chunk', [
3636 h('div.avatar'),
3737 h('div.msgs', map(chunk, msg => {
3838 return h('div.msg-row', [
@@ -41,9 +41,9 @@
4141 ])
4242 }))
4343 ])
4444 : h('div.other-chunk', [
45- h('div.avatar', when(author, api.about.html.image(author))),
45+ h('div.avatar', when(author, api.about.html.image(author()))),
4646 h('div.msgs', map(chunk, msg => {
4747 return h('div.msg-row', [
4848 message(msg),
4949 h('div.spacer')
app/page/home.jsView
@@ -1,9 +1,7 @@
11 const nest = require('depnest')
22 const { h } = require('mutant')
33
4-const dummyMsg = require('../../test/fixtures/thread')[0]
5-
64 exports.gives = nest('app.page.home')
75
86 exports.needs = nest({
97 'app.sync.goTo': 'first'
@@ -19,8 +17,9 @@
1917 return h('div', [
2018 h('h1', 'Home'),
2119 h('div', { 'ev-click': () => goTo({ page: 'home' }) }, 'Home'),
2220 h('div', { 'ev-click': () => goTo({ type: 'group', key: '%sadlkjas;lkdjas' }) }, 'Group'),
23- h('div', { 'ev-click': () => goTo(dummyMsg) }, 'Private message')
21+ h('div', { 'ev-click': () => goTo({key: '%fXXZgQrwnj7F+Y19H0IXxNriuvPFoahvusih3UzpkfA=.sha256'}) }, 'Private Thread A'),
22+ h('div', { 'ev-click': () => goTo({key: '%3cWZHeN6k03XpvDBxrxP5bGLsNByFLTvr/rKYFV4f+c=.sha256'}) }, 'Private Thread B'),
2423 ])
2524 }
2625 }
app/page/private.jsView
@@ -1,9 +1,8 @@
11 const nest = require('depnest')
22 const { h } = require('mutant')
33
44 const pull = require('pull-stream')
5-const dummyThread = require('../../test/fixtures/thread')
65
76 exports.gives = nest('app.page.private')
87
98 exports.needs = nest({
@@ -17,13 +16,10 @@
1716 function private (location) {
1817 // location here can expected to be an ssb-message
1918 const { goTo } = api.app.sync
2019
21- // TODO (mix) : swap for actual source, derived from location
20+ const thread = api.app.html.thread(location.key)
2221
23- const id = '%fXXZgQrwnj7F+Y19H0IXxNriuvPFoahvusih3UzpkfA=.sha256'
24- const thread = api.app.html.thread(id)
25-
2622 return h('div', [
2723 h('h1', 'Private message'),
2824 h('div', { 'ev-click': () => goTo({ page: 'home' }) }, 'Home'),
2925 thread

Built with git-ssb-web