FIX: going from /categories to /latest on mobile might break infinite scrolling
This commit is contained in:
parent
ba0e322fd0
commit
12bab65167
|
@ -48,11 +48,13 @@ class CategoriesController < ApplicationController
|
|||
|
||||
if style == "categories_and_latest_topics".freeze
|
||||
@topic_list = TopicQuery.new(current_user, topic_options).list_latest
|
||||
@topic_list.more_topics_url = url_for(public_send("latest_path"))
|
||||
elsif style == "categories_and_top_topics".freeze
|
||||
@topic_list = TopicQuery.new(nil, topic_options).list_top_for(SiteSetting.top_page_default_timeframe.to_sym)
|
||||
@topic_list.more_topics_url = url_for(public_send("top_path"))
|
||||
end
|
||||
|
||||
if @topic_list.present?
|
||||
if @topic_list.present? && @topic_list.topics.present?
|
||||
store_preloaded(
|
||||
@topic_list.preload_key,
|
||||
MultiJson.dump(TopicListSerializer.new(@topic_list, scope: guardian))
|
||||
|
|
|
@ -401,7 +401,7 @@ class TopicQuery
|
|||
end
|
||||
|
||||
list = TopicList.new(filter, @user, topics, options.merge(@options))
|
||||
list.per_page = per_page_setting
|
||||
list.per_page = options[:per_page] || per_page_setting
|
||||
list
|
||||
end
|
||||
|
||||
|
|
|
@ -26,6 +26,13 @@ describe CategoriesController do
|
|||
expect(html.css('body.crawler')).to be_present
|
||||
expect(html.css("a[href=\"/forum/c/#{category.slug}\"]")).to be_present
|
||||
end
|
||||
|
||||
it "properly preloads topic list" do
|
||||
SiteSetting.categories_topics = 5
|
||||
SiteSetting.categories_topics.times { Fabricate(:topic) }
|
||||
get "/categories"
|
||||
expect(response.body).to include(%{"more_topics_url":"/latest"})
|
||||
end
|
||||
end
|
||||
|
||||
context 'extensibility event' do
|
||||
|
|
Loading…
Reference in New Issue