Merge pull request #3723 from tgxworld/remove_sequential_rendering_of_time_gap

FIX: Timegap only shows up for sequential posts.
This commit is contained in:
Sam 2015-09-15 08:28:45 +10:00
commit 8bcb22f52d
3 changed files with 9 additions and 12 deletions

View File

@ -2,6 +2,8 @@ import SmallActionComponent from 'discourse/components/small-action';
export default SmallActionComponent.extend({
classNames: ['time-gap'],
classNameBindings: ['hideTimeGap::hidden'],
hideTimeGap: Em.computed.alias('postStream.hasNoFilters'),
icon: 'clock-o',
description: function() {

View File

@ -5,18 +5,13 @@ function calcDayDiff(p1, p2) {
if (!p1) { return; }
const date = p1.get('created_at');
if (date) {
if (p2) {
const numDiff = p1.get('post_number') - p2.get('post_number');
if (numDiff === 1) {
const lastDate = p2.get('created_at');
if (lastDate) {
const delta = new Date(date).getTime() - new Date(lastDate).getTime();
const days = Math.round(delta / (1000 * 60 * 60 * 24));
if (date && p2) {
const lastDate = p2.get('created_at');
if (lastDate) {
const delta = new Date(date).getTime() - new Date(lastDate).getTime();
const days = Math.round(delta / (1000 * 60 * 60 * 24));
p1.set('daysSincePrevious', days);
}
}
p1.set('daysSincePrevious', days);
}
}
}

View File

@ -1,7 +1,7 @@
{{post-gap post=this postStream=controller.model.postStream before="true"}}
{{#if hasTimeGap}}
{{time-gap daysAgo=daysSincePrevious}}
{{time-gap daysAgo=daysSincePrevious postStream=controller.model.postStream}}
{{/if}}
<div class='row'>