From 33e0de94f87a62c1a35dbb3acf20543247fd8ffa Mon Sep 17 00:00:00 2001
From: danielgrippi <danielgrippi@gmail.com>
Date: Thu, 29 Dec 2011 19:02:05 -0500
Subject: [PATCH] silently add a newly created Post to the stream's posts
 collection & fire stream.prependPost instead (this will make new posts show
 up top

---
 public/javascripts/app/views/feedback_view.js  | 8 +++++---
 public/javascripts/app/views/publisher_view.js | 8 +++++---
 public/javascripts/app/views/stream_view.js    | 9 +++++++++
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/public/javascripts/app/views/feedback_view.js b/public/javascripts/app/views/feedback_view.js
index 6aecaa03a4..489deb023f 100644
--- a/public/javascripts/app/views/feedback_view.js
+++ b/public/javascripts/app/views/feedback_view.js
@@ -32,9 +32,11 @@ app.views.Feedback = app.views.StreamObject.extend({
     if(window.confirm("Reshare " + this.model.baseAuthor().name + "'s post?")) {
       var reshare = new app.models.Reshare();
       reshare.save({root_guid : this.model.baseGuid()}, {
-        success : $.proxy(function(data){
-          app.stream.collection.add(this);
-        }, reshare)
+        success : function(data){
+          var newPost = new app.models.Post(data);
+          app.stream.collection.add(newPost, {silent : true});
+          app.stream.prependPost(newPost);
+        }
       });
       return reshare;
     }
diff --git a/public/javascripts/app/views/publisher_view.js b/public/javascripts/app/views/publisher_view.js
index e4943f5d0e..436752b048 100644
--- a/public/javascripts/app/views/publisher_view.js
+++ b/public/javascripts/app/views/publisher_view.js
@@ -27,9 +27,11 @@ app.views.Publisher = Backbone.View.extend({
       "aspect_ids" : serializedForm["aspect_ids[]"],
       "photos" : serializedForm["photos[]"]
     }, {
-      success : $.proxy(function(data) {
-        app.stream.collection.add(this);
-      }, statusMessage)
+      success : function(data) {
+        var newPost = new app.models.Post(data);
+        app.stream.collection.add(newPost, {silent : true});
+        app.stream.prependPost(newPost);
+      }
     });
 
     // clear state
diff --git a/public/javascripts/app/views/stream_view.js b/public/javascripts/app/views/stream_view.js
index b0eadb184c..af54a3da9d 100644
--- a/public/javascripts/app/views/stream_view.js
+++ b/public/javascripts/app/views/stream_view.js
@@ -12,9 +12,18 @@ app.views.Stream = Backbone.View.extend({
     return this;
   },
 
+  prependPost : function(post) {
+    var postView = new app.views.Post({ model: post });
+    $(this.el).prepend(postView.render().el);
+
+    return this;
+  },
+
   appendPost: function(post) {
     var postView = new app.views.Post({ model: post });
     $(this.el).append(postView.render().el);
+
+    return this;
   },
 
   collectionFetched: function() {
-- 
GitLab