Commit 812915c19cefd38d411ff51fc9293bf41bb31639
fix message.html.render for about messages
mixmix committed on 12/4/2018, 2:41:01 AMParent: b646c50c6df0318aa13a4c05977b089df80e370a
Files changed
message/html/render/about.js | changed |
message/html/render/about.js | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 … | const nest = require('depnest') |
2 | 2 … | const extend = require('xtend') |
3 | -const ref = require('ssb-ref') | |
3 … | +const { isFeed, isMsg, isBlob } = require('ssb-ref') | |
4 | 4 … | const { h } = require('mutant') |
5 | 5 … | |
6 | 6 … | exports.gives = nest('message.html.render') |
7 | 7 … | |
@@ -17,15 +17,17 @@ | ||
17 | 17 … | exports.create = function (api) { |
18 | 18 … | return nest('message.html.render', about) |
19 | 19 … | |
20 | 20 … | function about (msg, opts) { |
21 … | + // TODO write schemas for different sorts of about message | |
21 | 22 … | if (msg.value.content.type !== 'about') return |
22 | 23 … | |
23 | 24 … | const { name, description, image, about } = msg.value.content |
24 | 25 … | if (!name && !description && !image) return |
26 … | + if (!isFeed(about)) return | |
27 … | + // mix : note this looked like it was intended to deal with all about message but the logic sucked | |
28 … | + // I've made it explicitly handle only about messages for people, as that's what it was actually doing | |
25 | 29 … | |
26 | - if (ref.isMsg(about)) return | |
27 | - | |
28 | 30 … | const element = api.message.html.layout(msg, extend({ |
29 | 31 … | content: renderContent(msg), |
30 | 32 … | layout: 'default' |
31 | 33 … | }, opts)) |
@@ -38,9 +40,9 @@ | ||
38 | 40 … | var { about, link, name, description, image } = content |
39 | 41 … | if (!about) return |
40 | 42 … | |
41 | 43 … | // TODO : build better normalizers |
42 | - if (image && ref.isBlob(image.link)) image = image.link | |
44 … | + if (image && isBlob(image.link)) image = image.link | |
43 | 45 … | about = about || link |
44 | 46 … | |
45 | 47 … | const metaData = [ |
46 | 48 … | typeof name === 'string' |
@@ -53,18 +55,18 @@ | ||
53 | 55 … | ? h('img', { src: api.blob.sync.url(image), style: { 'margin-top': '.5rem' } }) |
54 | 56 … | : undefined |
55 | 57 … | ] |
56 | 58 … | |
57 | - if (!ref.isFeed(about)) { | |
58 | - return [ | |
59 | - h('p', [ | |
60 | - 'Describes ', | |
61 | - h('a', { href: about }, [about.slice(0, 7), '...']), | |
62 | - ' as: ' | |
63 | - ]), | |
64 | - ...metaData | |
65 | - ] | |
66 | - } | |
59 … | + // if (!isFeed(about)) { | |
60 … | + // return [ | |
61 … | + // h('p', [ | |
62 … | + // 'Describes ', | |
63 … | + // h('a', { href: about }, [about.slice(0, 7), '...']), | |
64 … | + // ' as: ' | |
65 … | + // ]), | |
66 … | + // ...metaData | |
67 … | + // ] | |
68 … | + // } | |
67 | 69 … | |
68 | 70 … | const target = author === about |
69 | 71 … | ? 'themself ' |
70 | 72 … | : api.about.html.link(about) |
Built with git-ssb-web