Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ If so, please delete it since it will prevent the federation from working proper * Use id as fallback when sorting posts [#7523](https://github.com/diaspora/diaspora/pull/7523) * Remove no-posts-info when adding posts to the stream [#7523](https://github.com/diaspora/diaspora/pull/7523) * Upgrade to rails 5.1 [#7514](https://github.com/diaspora/diaspora/pull/7514) * Refactoring single post view interactions [#7182](https://github.com/diaspora/diaspora/pull/7182) ## Bug fixes Loading app/assets/javascripts/app/models/post.js +0 −6 Original line number Diff line number Diff line Loading @@ -48,12 +48,6 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, var body = this.get("text").trim() , newlineIdx = body.indexOf("\n"); return (newlineIdx > 0 ) ? body.substr(newlineIdx+1, body.length) : ""; }, //returns a promise preloadOrFetch : function(){ var action = app.hasPreload("post") ? this.set(app.parsePreload("post")) : this.fetch(); return $.when(action); } })); // @license-end Loading app/assets/javascripts/app/models/post/interactions.js +3 −24 Original line number Diff line number Diff line Loading @@ -3,10 +3,6 @@ //require ../post app.models.Post.Interactions = Backbone.Model.extend({ url : function(){ return this.post.url() + "/interactions"; }, initialize : function(options){ this.post = options.post; this.comments = new app.collections.Comments(this.get("comments"), {post : this.post}); Loading @@ -14,33 +10,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(){ Loading app/assets/javascripts/app/pages/single-post-viewer.js +2 −3 Original line number Diff line number Diff line Loading @@ -9,9 +9,8 @@ app.pages.SinglePostViewer = app.views.Base.extend({ }, initialize : function() { this.model = new app.models.Post({ id : gon.post.id }); this.model.preloadOrFetch().done(_.bind(this.initViews, this)); this.model.interactions.fetch(); //async, yo, might want to throttle this later. this.model = new app.models.Post(gon.post); this.initViews(); }, initViews : function() { Loading app/assets/javascripts/app/router.js +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ app.Router = Backbone.Router.extend({ }, singlePost: function(id) { this.renderPage(function() { return new app.pages.SinglePostViewer({id: id}); }); this.renderPage(function() { return new app.pages.SinglePostViewer({id: id, el: $("#container")}); }); }, spotlight: function() { Loading Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ If so, please delete it since it will prevent the federation from working proper * Use id as fallback when sorting posts [#7523](https://github.com/diaspora/diaspora/pull/7523) * Remove no-posts-info when adding posts to the stream [#7523](https://github.com/diaspora/diaspora/pull/7523) * Upgrade to rails 5.1 [#7514](https://github.com/diaspora/diaspora/pull/7514) * Refactoring single post view interactions [#7182](https://github.com/diaspora/diaspora/pull/7182) ## Bug fixes Loading
app/assets/javascripts/app/models/post.js +0 −6 Original line number Diff line number Diff line Loading @@ -48,12 +48,6 @@ app.models.Post = Backbone.Model.extend(_.extend({}, app.models.formatDateMixin, var body = this.get("text").trim() , newlineIdx = body.indexOf("\n"); return (newlineIdx > 0 ) ? body.substr(newlineIdx+1, body.length) : ""; }, //returns a promise preloadOrFetch : function(){ var action = app.hasPreload("post") ? this.set(app.parsePreload("post")) : this.fetch(); return $.when(action); } })); // @license-end Loading
app/assets/javascripts/app/models/post/interactions.js +3 −24 Original line number Diff line number Diff line Loading @@ -3,10 +3,6 @@ //require ../post app.models.Post.Interactions = Backbone.Model.extend({ url : function(){ return this.post.url() + "/interactions"; }, initialize : function(options){ this.post = options.post; this.comments = new app.collections.Comments(this.get("comments"), {post : this.post}); Loading @@ -14,33 +10,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(){ Loading
app/assets/javascripts/app/pages/single-post-viewer.js +2 −3 Original line number Diff line number Diff line Loading @@ -9,9 +9,8 @@ app.pages.SinglePostViewer = app.views.Base.extend({ }, initialize : function() { this.model = new app.models.Post({ id : gon.post.id }); this.model.preloadOrFetch().done(_.bind(this.initViews, this)); this.model.interactions.fetch(); //async, yo, might want to throttle this later. this.model = new app.models.Post(gon.post); this.initViews(); }, initViews : function() { Loading
app/assets/javascripts/app/router.js +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ app.Router = Backbone.Router.extend({ }, singlePost: function(id) { this.renderPage(function() { return new app.pages.SinglePostViewer({id: id}); }); this.renderPage(function() { return new app.pages.SinglePostViewer({id: id, el: $("#container")}); }); }, spotlight: function() { Loading