Commit b51fde82e0d57c7264d7575dde85df093d30b696
ensure author avatar loads when ready
mix irving committed on 8/9/2017, 1:38:04 AMParent: 963223adf0b2978b4a3b94648b98620052008579
Files changed
app/html/app.js | changed |
app/html/thread.js | changed |
app/page/home.js | changed |
app/page/private.js | changed |
app/html/app.js | ||
---|---|---|
@@ -15,8 +15,7 @@ | ||
15 | 15 | function app () { |
16 | 16 | const css = values(api.styles.css()).join('\n') |
17 | 17 | insertCss(css) |
18 | 18 | |
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' }) | |
21 | 20 | } |
22 | 21 | } |
app/html/thread.js | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 | exports.needs = nest({ |
10 | 10 | 'about.html.image': 'first', |
11 | 11 | 'app.sync.goTo': 'first', |
12 | 12 | 'feed.obs.thread': 'first', |
13 | + 'keys.sync.id': 'first', | |
13 | 14 | 'message.html.markdown': 'first' |
14 | 15 | }) |
15 | 16 | |
16 | 17 | exports.create = (api) => { |
@@ -19,20 +20,19 @@ | ||
19 | 20 | function thread (id) { |
20 | 21 | // location here can expected to be: { page: 'home' } |
21 | 22 | |
22 | 23 | |
23 | - var myId = '@EMovhfIrFk4NihAKnRNhrfRaqIhBv1Wj8pTxJNgvCCY=.ed25519' | |
24 | - // TODO (mix) use keys.sync.id | |
24 | + var myId = api.keys.sync.id() | |
25 | 25 | |
26 | 26 | const thread = api.feed.obs.thread(id) |
27 | 27 | const chunkedMessages = buildChunkedMessages(thread.messages) |
28 | 28 | |
29 | 29 | const { goTo } = api.app.sync |
30 | 30 | const threadView = h('Thread', |
31 | 31 | map(chunkedMessages, chunk => { |
32 | - const author = get(chunk, '[0].value.author') | |
32 | + const author = computed([chunk], chunk => get(chunk, '[0].value.author')) | |
33 | 33 | |
34 | - return author === myId | |
34 | + return author() === myId | |
35 | 35 | ? h('div.my-chunk', [ |
36 | 36 | h('div.avatar'), |
37 | 37 | h('div.msgs', map(chunk, msg => { |
38 | 38 | return h('div.msg-row', [ |
@@ -41,9 +41,9 @@ | ||
41 | 41 | ]) |
42 | 42 | })) |
43 | 43 | ]) |
44 | 44 | : 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()))), | |
46 | 46 | h('div.msgs', map(chunk, msg => { |
47 | 47 | return h('div.msg-row', [ |
48 | 48 | message(msg), |
49 | 49 | h('div.spacer') |
app/page/home.js | ||
---|---|---|
@@ -1,9 +1,7 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | 2 | const { h } = require('mutant') |
3 | 3 | |
4 | -const dummyMsg = require('../../test/fixtures/thread')[0] | |
5 | - | |
6 | 4 | exports.gives = nest('app.page.home') |
7 | 5 | |
8 | 6 | exports.needs = nest({ |
9 | 7 | 'app.sync.goTo': 'first' |
@@ -19,8 +17,9 @@ | ||
19 | 17 | return h('div', [ |
20 | 18 | h('h1', 'Home'), |
21 | 19 | h('div', { 'ev-click': () => goTo({ page: 'home' }) }, 'Home'), |
22 | 20 | 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'), | |
24 | 23 | ]) |
25 | 24 | } |
26 | 25 | } |
app/page/private.js | ||
---|---|---|
@@ -1,9 +1,8 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | 2 | const { h } = require('mutant') |
3 | 3 | |
4 | 4 | const pull = require('pull-stream') |
5 | -const dummyThread = require('../../test/fixtures/thread') | |
6 | 5 | |
7 | 6 | exports.gives = nest('app.page.private') |
8 | 7 | |
9 | 8 | exports.needs = nest({ |
@@ -17,13 +16,10 @@ | ||
17 | 16 | function private (location) { |
18 | 17 | // location here can expected to be an ssb-message |
19 | 18 | const { goTo } = api.app.sync |
20 | 19 | |
21 | - // TODO (mix) : swap for actual source, derived from location | |
20 | + const thread = api.app.html.thread(location.key) | |
22 | 21 | |
23 | - const id = '%fXXZgQrwnj7F+Y19H0IXxNriuvPFoahvusih3UzpkfA=.sha256' | |
24 | - const thread = api.app.html.thread(id) | |
25 | - | |
26 | 22 | return h('div', [ |
27 | 23 | h('h1', 'Private message'), |
28 | 24 | h('div', { 'ev-click': () => goTo({ page: 'home' }) }, 'Home'), |
29 | 25 | thread |
Built with git-ssb-web