diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index bcb16a112..e84694c73 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -3,7 +3,7 @@ # the COPYRIGHT file. module StreamHelper - def next_page_path + def next_page_path(opts ={}) if controller.instance_of?(TagsController) tag_path(@tag, :max_time => @posts.last.created_at.to_i) elsif controller.instance_of?(AppsController) @@ -13,7 +13,13 @@ module StreamHelper elsif controller.instance_of?(TagFollowingsController) tag_followings_path(:max_time => @stream.posts.last.created_at.to_i) elsif controller.instance_of?(AspectsController) - aspects_path(:max_time => @stream.posts.last.send(@stream.order.to_sym).to_i, :a_ids => @stream.aspect_ids) + if opts[:ajax_stream] + time = (Time.now() + 1).to_i + + else + time = @stream.posts.last.send(@stream.order.to_sym).to_i + end + aspects_path(:max_time => time, :a_ids => @stream.aspect_ids) else raise 'in order to use pagination for this new controller, update next_page_path in stream helper' end diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index d2b59a43f..a5c08171a 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -26,7 +26,12 @@ .span-13.append-1 #aspect_stream_container.stream_container - = render 'aspects/aspect_stream', :stream => @stream + + = render 'shared/publisher', :selected_aspects => @stream.aspects, :aspect_ids => @stream.aspect_ids, :for_all_aspects => @stream.for_all_aspects?, :aspect => @stream.aspect + #main_stream.stream{:data => {:guids => @stream.aspect_ids.join(',')}} + #pagination + =link_to(t('more'), next_page_path(:ajax_stream => true), :class => 'paginate') + /= render 'aspects/aspect_stream', :stream => @stream .span-5.rightBar.last = render 'aspects/selected_contacts', :stream => @stream diff --git a/public/javascripts/widgets/infinite-scroll.js b/public/javascripts/widgets/infinite-scroll.js index 9dbee19e6..36ca113c5 100644 --- a/public/javascripts/widgets/infinite-scroll.js +++ b/public/javascripts/widgets/infinite-scroll.js @@ -19,6 +19,12 @@ var newPath = pathStr.replace("?", "?only_posts=true&"), lastTime = $('#main_stream .stream_element').last().find(".time").attr("integer"); + if(lastTime === undefined){ + var currentTime = new Date, + unixtimeMs = currentTime.getTime(), + lastTime = parseInt(unixtimeMs / 1000); + } + return newPath.replace(/max_time=\d+/, "max_time=" + lastTime); } };