mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
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:
commit
8bcb22f52d
3 changed files with 9 additions and 12 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'>
|
||||
|
|
Loading…
Reference in a new issue