diff --git a/app/models/post.rb b/app/models/post.rb index ffda79016..6af603919 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -35,13 +35,7 @@ class Post < ActiveRecord::Base t.add :o_embed_cache t.add :user_like t.add :mentioned_people - t.add lambda { |post| - if post.respond_to?(:photos) - post.photos - else - [] - end - }, :as => :photos + t.add :photos end xml_attr :provider_display_name diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 7caaeb999..82f1c4eb3 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -41,6 +41,10 @@ class Reshare < Post self.root ? root.mentioned_people : super end + def photos + self.root ? root.photos : super + end + def receive(recipient, sender) local_reshare = Reshare.where(:guid => self.guid).first if local_reshare && local_reshare.root.author_id == recipient.person.id diff --git a/public/javascripts/app/templates/reshare.handlebars b/public/javascripts/app/templates/reshare.handlebars index 131c5dd48..64add00e8 100644 --- a/public/javascripts/app/templates/reshare.handlebars +++ b/public/javascripts/app/templates/reshare.handlebars @@ -27,12 +27,12 @@ {{t "stream.reshares" count=reshares_count}} {{/if}} - - {{> status-message}} - - {{/with}} + {{> status-message}} + + + {{else}}

diff --git a/public/javascripts/app/views/content_view.js b/public/javascripts/app/views/content_view.js index 0287b7bf3..fe2b20a0d 100644 --- a/public/javascripts/app/views/content_view.js +++ b/public/javascripts/app/views/content_view.js @@ -1,12 +1,10 @@ app.views.Content = app.views.StreamObject.extend({ - presenter : function(model){ - var model = model || this.model - + presenter : function(){ return _.extend(this.defaultPresenter(), { - text : app.helpers.textFormatter(model), - o_embed_html : embedHTML(model), - largePhoto : this.largePhoto(model), - smallPhotos : this.smallPhotos(model) + text : app.helpers.textFormatter(this.model), + o_embed_html : embedHTML(this.model), + largePhoto : this.largePhoto(), + smallPhotos : this.smallPhotos() }) function embedHTML(model){ @@ -20,22 +18,16 @@ app.views.Content = app.views.StreamObject.extend({ } }, - largePhoto : function(model) { - var photos = model.get("photos") + largePhoto : function() { + var photos = this.model.get("photos") if(!photos || photos.length == 0) { return } return photos[0] }, - smallPhotos : function(model) { - var photos = model.get("photos") + smallPhotos : function() { + var photos = this.model.get("photos") if(!photos || photos.length < 2) { return } return photos.slice(1,8) - }, - - // should be a private function in this.presenter() - rootPresenter : function(model) { - if(!model || !model.get("root")) { return } - return this.presenter(new app.models.Post(model.get("root"))) } })