From b9f82641b04fd1b879075feaa80931f830b063c2 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 24 May 2016 17:13:56 -0400 Subject: [PATCH] UX: Hide all timeline controls when fewer than 3 posts --- .../discourse/widgets/topic-timeline.js.es6 | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 3e5f9991194..392061a23bb 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -209,6 +209,9 @@ export default createWidget('topic-timeline', { html(attrs) { const { topic } = attrs; const createdAt = new Date(topic.created_at); + const stream = attrs.topic.get('postStream.stream'); + + if (stream.length < 3) { return; } const controls = []; if (attrs.topic.get('details.can_create_post')) { @@ -225,25 +228,18 @@ export default createWidget('topic-timeline', { controls.push(this.attach('topic-admin-menu-button', { topic })); } - const result = [ h('div.timeline-controls', controls) ]; - const stream = attrs.topic.get('postStream.stream'); - if (stream.length > 2) { - return result.concat([ - this.attach('link', { - className: 'start-date', - rawLabel: moment(createdAt).format(I18n.t('dates.timeline_start')), - action: 'jumpTop' - }), - this.attach('timeline-scrollarea', attrs), - this.attach('link', { - className: 'now-date', - icon: 'dot-circle-o', - rawLabel: relativeAge(new Date(topic.last_posted_at), { addAgo: true }), - action: 'jumpBottom' - }) - ]); - } - - return result; + return [ h('div.timeline-controls', controls), + this.attach('link', { + className: 'start-date', + rawLabel: moment(createdAt).format(I18n.t('dates.timeline_start')), + action: 'jumpTop' + }), + this.attach('timeline-scrollarea', attrs), + this.attach('link', { + className: 'now-date', + icon: 'dot-circle-o', + rawLabel: relativeAge(new Date(topic.last_posted_at), { addAgo: true }), + action: 'jumpBottom' + }) ]; } });