From 6df84ed7034537e99a7d3c11e528eca3e893a533 Mon Sep 17 00:00:00 2001 From: Asphyxia Date: Sun, 27 Jan 2013 05:39:29 -0300 Subject: [PATCH] Fix wrong message on infinite scroll on contact page --- Changelog.md | 1 + .../javascripts/pages/contacts-index.js | 3 ++- .../javascripts/widgets/infinite-scroll.js | 3 ++- config/locales/javascript/javascript.en.yml | 1 + .../javascripts/app/views/stream_view_spec.js | 26 ++++++++++++++++--- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index ff4b828e1..9f8e38f53 100644 --- a/Changelog.md +++ b/Changelog.md @@ -54,6 +54,7 @@ * Show timestamp hovering a timeago string (stream) [#3149](https://github.com/diaspora/diaspora/issues/3149) * Fix reshare and like a post on a single post view [#3672](https://github.com/diaspora/diaspora/issues/3672) * Fix posting multiple times the same content [#3272](https://github.com/diaspora/diaspora/issues/3272) +* Fix wrong message on infinite scroll on contacts page [#3681](https://github.com/diaspora/diaspora/issues/3681) ## Gem Updates diff --git a/app/assets/javascripts/pages/contacts-index.js b/app/assets/javascripts/pages/contacts-index.js index 2f4dd6071..c570dfd6c 100644 --- a/app/assets/javascripts/pages/contacts-index.js +++ b/app/assets/javascripts/pages/contacts-index.js @@ -2,7 +2,8 @@ Diaspora.Pages.ContactsIndex = function() { var self = this; this.subscribe("page/ready", function(evt, document) { - self.infiniteScroll = self.instantiate("InfiniteScroll"); + self.infiniteScroll = self.instantiate("InfiniteScroll", + {donetext: Diaspora.I18n.t("infinite_scroll.no_more_contacts"),}); $('.conversation_button').tooltip({placement: 'bottom'}); }); diff --git a/app/assets/javascripts/widgets/infinite-scroll.js b/app/assets/javascripts/widgets/infinite-scroll.js index 38b826a91..dbf78b937 100644 --- a/app/assets/javascripts/widgets/infinite-scroll.js +++ b/app/assets/javascripts/widgets/infinite-scroll.js @@ -27,7 +27,8 @@ } }; - this.subscribe("widget/ready", function() { + this.subscribe("widget/ready", function(evt, opts) { + $.extend(self.options, opts); if($('#main_stream').length !== 0) { $('#main_stream').infinitescroll(self.options, function(newElements) { self.globalPublish("stream/scrolled", newElements); diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index 83e95433e..562e92611 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -43,6 +43,7 @@ en: public: "Public - your post will be visible to everyone and found by search engines" infinite_scroll: no_more: "No more posts." + no_more_contacts: "No more contacts." aspect_dropdown: add_to_aspect: "Add contact" select_aspects: "Select aspects" diff --git a/spec/javascripts/app/views/stream_view_spec.js b/spec/javascripts/app/views/stream_view_spec.js index b0a696274..dac66b2fc 100644 --- a/spec/javascripts/app/views/stream_view_spec.js +++ b/spec/javascripts/app/views/stream_view_spec.js @@ -39,21 +39,39 @@ describe("app.views.Stream", function() { describe("infScroll", function() { // NOTE: inf scroll happens at 500px - - it("fetches moar when the user is at the bottom of the page", function() { + beforeEach(function(){ spyOn($.fn, "height").andReturn(0); spyOn($.fn, "scrollTop").andReturn(100); spyOn(this.view.model, "fetch"); + }); + + it("fetches moar when the user is at the bottom of the page", function() { this.view.infScroll(); waitsFor(function(){ return this.view.model.fetch.wasCalled - }, "the infinite scroll function didn't fetch the stream") + }, "the infinite scroll function didn't fetch the stream"); runs(function(){ expect(this.view.model.fetch).toHaveBeenCalled() - }) + }); + }); + + it("shows the loader while fetching new posts", function() { + spyOn(this.view, "showLoader"); + this.view.infScroll(); + + expect(this.view.showLoader).toHaveBeenCalled(); + }); + + + it("doesnt try to fetch more content if already fetched all", function() { + spyOn($.fn, "unbind"); + + this.stream.trigger("allItemsLoaded", this.view); + + expect($.fn.unbind).toHaveBeenCalledWith("scroll"); }); });