silently add a newly created Post to the stream's posts collection & fire stream.prependPost instead (this will make new posts show up top

This commit is contained in:
danielgrippi 2011-12-29 19:02:05 -05:00 committed by Dennis Collinson
parent 565a0b21f7
commit 33e0de94f8
3 changed files with 19 additions and 6 deletions

View file

@ -32,9 +32,11 @@ app.views.Feedback = app.views.StreamObject.extend({
if(window.confirm("Reshare " + this.model.baseAuthor().name + "'s post?")) { if(window.confirm("Reshare " + this.model.baseAuthor().name + "'s post?")) {
var reshare = new app.models.Reshare(); var reshare = new app.models.Reshare();
reshare.save({root_guid : this.model.baseGuid()}, { reshare.save({root_guid : this.model.baseGuid()}, {
success : $.proxy(function(data){ success : function(data){
app.stream.collection.add(this); var newPost = new app.models.Post(data);
}, reshare) app.stream.collection.add(newPost, {silent : true});
app.stream.prependPost(newPost);
}
}); });
return reshare; return reshare;
} }

View file

@ -27,9 +27,11 @@ app.views.Publisher = Backbone.View.extend({
"aspect_ids" : serializedForm["aspect_ids[]"], "aspect_ids" : serializedForm["aspect_ids[]"],
"photos" : serializedForm["photos[]"] "photos" : serializedForm["photos[]"]
}, { }, {
success : $.proxy(function(data) { success : function(data) {
app.stream.collection.add(this); var newPost = new app.models.Post(data);
}, statusMessage) app.stream.collection.add(newPost, {silent : true});
app.stream.prependPost(newPost);
}
}); });
// clear state // clear state

View file

@ -12,9 +12,18 @@ app.views.Stream = Backbone.View.extend({
return this; return this;
}, },
prependPost : function(post) {
var postView = new app.views.Post({ model: post });
$(this.el).prepend(postView.render().el);
return this;
},
appendPost: function(post) { appendPost: function(post) {
var postView = new app.views.Post({ model: post }); var postView = new app.views.Post({ model: post });
$(this.el).append(postView.render().el); $(this.el).append(postView.render().el);
return this;
}, },
collectionFetched: function() { collectionFetched: function() {