From 781358df92665a6806ef6946d8fd140f88cf6302 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 5 Nov 2017 19:34:01 -0500 Subject: Special case about messages for names --- lib/render-msg.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/render-msg.js b/lib/render-msg.js index 1fd4d83..88224f0 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -464,11 +464,23 @@ var knownAboutProps = { } RenderMsg.prototype.about = function (cb) { + var keys = Object.keys(this.c).sort().join() + var isSelf = this.c.about === this.msg.value.author + + if (keys === 'about,name,type') { + return this.wrapMini([ + isSelf ? + 'self-identifies as ' : + ['identifies ', h('a', {href: this.toUrl(this.c.about)}, truncate(this.c.about, 10)), ' as '], + h('ins', this.c.name) + ], cb) + } + var done = multicb({pluck: 1, spread: true}) var elCb = done() var isAttendingMsg = u.linkDest(this.c.attendee) === this.msg.value.author - && Object.keys(this.c).sort().join() === 'about,attendee,type' + && keys === 'about,attendee,type' if (isAttendingMsg) { var attending = !this.c.attendee.remove this.wrapMini([ @@ -489,23 +501,20 @@ RenderMsg.prototype.about = function (cb) { var img = u.linkDest(this.c.image) // if there is a description, it is likely to be multi-line var hasDescription = this.c.description != null - var wrap = hasDescription ? this.wrap : this.wrapMini - var isSelf = this.c.about === this.msg.value.author // if this about message gives the thing a name, show its id var showComputedName = !isSelf && !this.c.name - wrap.call(this, [ + this.wrap([ this.c.root ? h('div', h('small', '> ', this.link1(this.c.root, done())) ) : '', - isSelf - ? hasDescription ? 'self-describes' : 'self-identifies' - : [hasDescription ? 'describes' : 'identifies', ' ', - !this.c.about ? '?' + isSelf ? 'self-describes as ' : [ + 'describes ', + !this.c.about ? '' : showComputedName ? this.link1(this.c.about, done()) - : h('a', {href: this.toUrl(this.c.about)}, truncate(this.c.about, 10)) - ], - ' as ', + : h('a', {href: this.toUrl(this.c.about)}, truncate(this.c.about, 10)), + ' as ' + ], this.c.name ? [h('ins', this.c.name), ' '] : '', this.c.description ? h('div', {innerHTML: this.render.markdown(this.c.description)}) : '', -- cgit v1.2.3