From ad53a43f888acdbe99c2d0fb84e987843dded8bd Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Sat, 12 Nov 2016 14:30:35 +0100 Subject: [PATCH] Remove unused post interactions parse method --- .../app/models/post/interactions.js | 23 +++---------------- .../single_post_comment_stream.js | 1 - .../single_post_comment_stream_spec.js | 8 ------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index b3700b97d..c7db08827 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -14,33 +14,16 @@ app.models.Post.Interactions = Backbone.Model.extend({ this.reshares = new app.collections.Reshares(this.get("reshares"), {post : this.post}); }, - parse : function(resp){ - this.comments.reset(resp.comments); - this.likes.reset(resp.likes); - this.reshares.reset(resp.reshares); - - var comments = this.comments - , likes = this.likes - , reshares = this.reshares; - - return { - comments : comments, - likes : likes, - reshares : reshares, - fetched : true - }; - }, - likesCount : function(){ - return this.get("fetched") ? this.likes.models.length : this.get("likes_count"); + return this.get("likes_count"); }, resharesCount : function(){ - return this.get("fetched") ? this.reshares.models.length : this.get("reshares_count"); + return this.get("reshares_count"); }, commentsCount : function(){ - return this.get("fetched") ? this.comments.models.length : this.get("comments_count"); + return this.get("comments_count"); }, userLike : function(){ diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js index 3e8ea0ea3..6981bdc3a 100644 --- a/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js +++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_comment_stream.js @@ -7,7 +7,6 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({ this.CommentView = app.views.ExpandedComment; $(window).on('hashchange',this.highlightPermalinkComment); this.setupBindings(); - this.model.comments.on("reset", this.render, this); this.model.comments.fetch({success: function() { setTimeout(this.highlightPermalinkComment, 0); }.bind(this)}); diff --git a/spec/javascripts/app/views/single-post-view/single_post_comment_stream_spec.js b/spec/javascripts/app/views/single-post-view/single_post_comment_stream_spec.js index 3e32ca3ee..28c80225d 100644 --- a/spec/javascripts/app/views/single-post-view/single_post_comment_stream_spec.js +++ b/spec/javascripts/app/views/single-post-view/single_post_comment_stream_spec.js @@ -9,14 +9,6 @@ describe("app.views.SinglePostCommentStream", function() { expect(this.view.CommentView).toBe(app.views.ExpandedComment); }); - it("calls render when the comments collection has been resetted", function() { - spyOn(app.views.SinglePostCommentStream.prototype, "render"); - this.view.initialize(); - expect(app.views.SinglePostCommentStream.prototype.render).not.toHaveBeenCalled(); - this.post.comments.reset(); - expect(app.views.SinglePostCommentStream.prototype.render).toHaveBeenCalled(); - }); - it("calls setupBindings", function() { spyOn(app.views.SinglePostCommentStream.prototype, "setupBindings"); this.view.initialize();