Loading Changelog.md +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ If so, please delete it since it will prevent the federation from working proper * Move back to top to the right to avoid misclicks [#7516](https://github.com/diaspora/diaspora/pull/7516) * Include count in mobile post action link [#7520](https://github.com/diaspora/diaspora/pull/7520) * Update the user data export archive format [#6726](https://github.com/diaspora/diaspora/pull/6726) * 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) ## Bug fixes Loading app/assets/javascripts/app/models/stream.js +10 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,15 @@ app.models.Stream = Backbone.Collection.extend({ collectionOptions :function(){ var order = this.sortOrder(); return { comparator : function(item) { return -item[order](); } }; return { comparator: function(item1, item2) { if (item1[order]() < item2[order]()) { return 1; } if (item1[order]() > item2[order]()) { return -1; } if (item1.id < item2.id) { return 1; } if (item1.id > item2.id) { return -1; } return 0; } }; }, url : function(){ Loading app/assets/javascripts/app/views/infinite_stream_view.js +6 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ app.views.InfScroll = app.views.Base.extend({ } }, postRenderTemplate: function() { if (this.postViews.length > 0) { this.$(".no-posts-info").closest(".stream-element").remove(); } }, showNoPostsInfo: function() { if (this.postViews.length === 0) { var noPostsInfo = new app.views.NoPostsInfo(); Loading spec/javascripts/app/models/stream_spec.js +32 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,38 @@ describe("app.models.Stream", function() { expectedPath = document.location.pathname; }); describe("collectionOptions", function() { beforeEach(function() { this.post1 = new app.models.Post({"id": 1, "created_at": 12, "interacted_at": 123}); this.post2 = new app.models.Post({"id": 2, "created_at": 13, "interacted_at": 123}); this.post3 = new app.models.Post({"id": 3, "created_at": 13, "interacted_at": 122}); this.post4 = new app.models.Post({"id": 4, "created_at": 10, "interacted_at": 100}); }); it("returns a comparator for posts that compares created_at and ids by default", function() { this.options = stream.collectionOptions(); expect(this.options.comparator(this.post1, this.post2)).toBe(1); expect(this.options.comparator(this.post2, this.post1)).toBe(-1); expect(this.options.comparator(this.post2, this.post3)).toBe(1); expect(this.options.comparator(this.post3, this.post2)).toBe(-1); expect(this.options.comparator(this.post1, this.post4)).toBe(-1); expect(this.options.comparator(this.post4, this.post1)).toBe(1); expect(this.options.comparator(this.post1, this.post1)).toBe(0); }); it("returns a comparator for posts that compares interacted_at and ids for the activity stream", function() { spyOn(stream, "basePath").and.returnValue("activity"); this.options = stream.collectionOptions(); expect(this.options.comparator(this.post1, this.post2)).toBe(1); expect(this.options.comparator(this.post2, this.post1)).toBe(-1); expect(this.options.comparator(this.post2, this.post3)).toBe(-1); expect(this.options.comparator(this.post3, this.post2)).toBe(1); expect(this.options.comparator(this.post1, this.post4)).toBe(-1); expect(this.options.comparator(this.post4, this.post1)).toBe(1); expect(this.options.comparator(this.post1, this.post1)).toBe(0); }); }); describe("#_fetchOpts", function() { it("it fetches posts from the window's url, and ads them to the collection", function() { expect( stream._fetchOpts() ).toEqual({ remove: false, url: expectedPath}); Loading Loading
Changelog.md +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ If so, please delete it since it will prevent the federation from working proper * Move back to top to the right to avoid misclicks [#7516](https://github.com/diaspora/diaspora/pull/7516) * Include count in mobile post action link [#7520](https://github.com/diaspora/diaspora/pull/7520) * Update the user data export archive format [#6726](https://github.com/diaspora/diaspora/pull/6726) * 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) ## Bug fixes Loading
app/assets/javascripts/app/models/stream.js +10 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,15 @@ app.models.Stream = Backbone.Collection.extend({ collectionOptions :function(){ var order = this.sortOrder(); return { comparator : function(item) { return -item[order](); } }; return { comparator: function(item1, item2) { if (item1[order]() < item2[order]()) { return 1; } if (item1[order]() > item2[order]()) { return -1; } if (item1.id < item2.id) { return 1; } if (item1.id > item2.id) { return -1; } return 0; } }; }, url : function(){ Loading
app/assets/javascripts/app/views/infinite_stream_view.js +6 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,12 @@ app.views.InfScroll = app.views.Base.extend({ } }, postRenderTemplate: function() { if (this.postViews.length > 0) { this.$(".no-posts-info").closest(".stream-element").remove(); } }, showNoPostsInfo: function() { if (this.postViews.length === 0) { var noPostsInfo = new app.views.NoPostsInfo(); Loading
spec/javascripts/app/models/stream_spec.js +32 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,38 @@ describe("app.models.Stream", function() { expectedPath = document.location.pathname; }); describe("collectionOptions", function() { beforeEach(function() { this.post1 = new app.models.Post({"id": 1, "created_at": 12, "interacted_at": 123}); this.post2 = new app.models.Post({"id": 2, "created_at": 13, "interacted_at": 123}); this.post3 = new app.models.Post({"id": 3, "created_at": 13, "interacted_at": 122}); this.post4 = new app.models.Post({"id": 4, "created_at": 10, "interacted_at": 100}); }); it("returns a comparator for posts that compares created_at and ids by default", function() { this.options = stream.collectionOptions(); expect(this.options.comparator(this.post1, this.post2)).toBe(1); expect(this.options.comparator(this.post2, this.post1)).toBe(-1); expect(this.options.comparator(this.post2, this.post3)).toBe(1); expect(this.options.comparator(this.post3, this.post2)).toBe(-1); expect(this.options.comparator(this.post1, this.post4)).toBe(-1); expect(this.options.comparator(this.post4, this.post1)).toBe(1); expect(this.options.comparator(this.post1, this.post1)).toBe(0); }); it("returns a comparator for posts that compares interacted_at and ids for the activity stream", function() { spyOn(stream, "basePath").and.returnValue("activity"); this.options = stream.collectionOptions(); expect(this.options.comparator(this.post1, this.post2)).toBe(1); expect(this.options.comparator(this.post2, this.post1)).toBe(-1); expect(this.options.comparator(this.post2, this.post3)).toBe(-1); expect(this.options.comparator(this.post3, this.post2)).toBe(1); expect(this.options.comparator(this.post1, this.post4)).toBe(-1); expect(this.options.comparator(this.post4, this.post1)).toBe(1); expect(this.options.comparator(this.post1, this.post1)).toBe(0); }); }); describe("#_fetchOpts", function() { it("it fetches posts from the window's url, and ads them to the collection", function() { expect( stream._fetchOpts() ).toEqual({ remove: false, url: expectedPath}); Loading