UX: Hide all timeline controls when fewer than 3 posts

This commit is contained in:
Robin Ward 2016-05-24 17:13:56 -04:00
parent 0e3b275684
commit b9f82641b0
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
1 changed files with 16 additions and 20 deletions

View File

@ -209,6 +209,9 @@ export default createWidget('topic-timeline', {
html(attrs) { html(attrs) {
const { topic } = attrs; const { topic } = attrs;
const createdAt = new Date(topic.created_at); const createdAt = new Date(topic.created_at);
const stream = attrs.topic.get('postStream.stream');
if (stream.length < 3) { return; }
const controls = []; const controls = [];
if (attrs.topic.get('details.can_create_post')) { 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 })); controls.push(this.attach('topic-admin-menu-button', { topic }));
} }
const result = [ h('div.timeline-controls', controls) ]; return [ h('div.timeline-controls', controls),
const stream = attrs.topic.get('postStream.stream'); this.attach('link', {
if (stream.length > 2) { className: 'start-date',
return result.concat([ rawLabel: moment(createdAt).format(I18n.t('dates.timeline_start')),
this.attach('link', { action: 'jumpTop'
className: 'start-date', }),
rawLabel: moment(createdAt).format(I18n.t('dates.timeline_start')), this.attach('timeline-scrollarea', attrs),
action: 'jumpTop' this.attach('link', {
}), className: 'now-date',
this.attach('timeline-scrollarea', attrs), icon: 'dot-circle-o',
this.attach('link', { rawLabel: relativeAge(new Date(topic.last_posted_at), { addAgo: true }),
className: 'now-date', action: 'jumpBottom'
icon: 'dot-circle-o', }) ];
rawLabel: relativeAge(new Date(topic.last_posted_at), { addAgo: true }),
action: 'jumpBottom'
})
]);
}
return result;
} }
}); });