diff --git a/app/models/post.rb b/app/models/post.rb index b2fdee258..ffda79016 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -21,6 +21,7 @@ class Post < ActiveRecord::Base }, :as => :text t.add :public t.add :created_at + t.add :interacted_at t.add :comments_count t.add :likes_count t.add :reshares_count diff --git a/public/javascripts/app/models/post.js b/public/javascripts/app/models/post.js index 3560276f8..cbd798cc7 100644 --- a/public/javascripts/app/models/post.js +++ b/public/javascripts/app/models/post.js @@ -6,7 +6,15 @@ app.models.Post = Backbone.Model.extend({ }, createdAt : function() { - return new Date(this.get("created_at")) / 1000; + return this.timeOf("created_at"); + }, + + interactedAt : function() { + return this.timeOf("interacted_at"); + }, + + timeOf: function(field) { + return new Date(this.get(field)) /1000; }, createReshareUrl : "/reshares", diff --git a/public/javascripts/app/models/stream.js b/public/javascripts/app/models/stream.js index edf9a49cb..77a93bdb9 100644 --- a/public/javascripts/app/models/stream.js +++ b/public/javascripts/app/models/stream.js @@ -42,7 +42,13 @@ app.models.Stream = Backbone.Collection.extend({ }, timeFilteredPath : function(){ - return this.basePath() + "?max_time=" + _.last(this.posts.models).createdAt(); + return this.basePath() + "?max_time=" + this.maxTime(); + }, + + maxTime: function(){ + var lastPost = _.last(this.posts.models); + var isOnParticipateStream = this.basePath().match(/participate/); + return (isOnParticipateStream == null) ? lastPost.createdAt() : lastPost.interactedAt(); }, add : function(models){