Commit ca490d878aac9b2af156d85f1eece0bb9c20f1d6
minor refactor
- move `profile` function into scope with `api`, rather than pass `api` as an argument. - change `h('div', { className: 'About' })` to `h('About')` which works with `micro-css/h` wrapping. - add code for where we would default `aboutId` to `authorId`, awaiting feedback from %ueXnRVeqvd2LZmq1HnYETwRxY3jfOdxHWrJhVApLBK4=.sha256Michael Williams committed on 12/20/2016, 9:50:41 AM
Parent: 40f0cb94a46d262deff9570160cc8b204c9b9f78
Files changed
modules_basic/about.js | changed |
modules_basic/about.js | ||
---|---|---|
@@ -1,8 +1,6 @@ | ||
1 | 1 … | var h = require('../h') |
2 | 2 … | |
3 | -//var blob_url = require('../plugs').first(exports.blob_url = []) | |
4 | - | |
5 | 3 … | exports.needs = { |
6 | 4 … | blob_url: 'first' |
7 | 5 … | } |
8 | 6 … | |
@@ -30,18 +28,31 @@ | ||
30 | 28 … | |
31 | 29 … | function message_content (msg) { |
32 | 30 … | if(msg.value.content.type !== 'about') return |
33 | 31 … | |
34 | - var about = msg.value.content | |
32 … | + var { value } = msg | |
33 … | + var { content: about, author: authorId } = value | |
35 | 34 … | var { about: aboutId, name, image, description } = about |
35 … | + // TODO does about default to the message author? | |
36 … | + // var { about: aboutId = authorId, name, image, description } = about | |
36 | 37 … | |
37 | - // if(!image && !name) return | |
38 | - | |
39 | - return h('div', {className: 'About'}, [ | |
38 … | + return h('About', [ | |
40 | 39 … | verb({ aboutId, authorId: msg.value.author }), |
41 | - profile({ aboutId, name, image, description, api }) | |
40 … | + profile({ aboutId, name, image, description }) | |
42 | 41 … | ]) |
43 | 42 … | } |
43 … | + | |
44 … | + function profile ({ aboutId, name, image, description }) { | |
45 … | + return h('div', [ | |
46 … | + name | |
47 … | + ? h('a', {href:'#'+aboutId}, name) | |
48 … | + : null, | |
49 … | + image | |
50 … | + ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)})) | |
51 … | + : null, | |
52 … | + description || null | |
53 … | + ]) | |
54 … | + } | |
44 | 55 … | } |
45 | 56 … | |
46 | 57 … | |
47 | 58 … | function verb ({ aboutId, authorId }) { |
@@ -51,20 +62,8 @@ | ||
51 | 62 … | |
52 | 63 … | return h('header', content) |
53 | 64 … | } |
54 | 65 … | |
55 | -function profile ({ aboutId, name, image, description, api }) { | |
56 | - return h('div', [ | |
57 | - name | |
58 | - ? h('a', {href:'#'+aboutId}, name) | |
59 | - : null, | |
60 | - image | |
61 | - ? h('a', {href:'#'+aboutId}, h('img.avatar--fullsize', {src: api.blob_url(image)})) | |
62 | - : null, | |
63 | - description || null | |
64 | - ]) | |
65 | -} | |
66 | - | |
67 | 66 … | function idLink (id) { |
68 | 67 … | if (!id) return null |
69 | 68 … | |
70 | 69 … | return h('a', {href:'#'+id}, id.slice(0,9) + '...') |
Built with git-ssb-web