mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: going from /categories to /latest on mobile might break infinite scrolling
This commit is contained in:
@ -48,11 +48,13 @@ class CategoriesController < ApplicationController
|
|||||||
|
|
||||||
if style == "categories_and_latest_topics".freeze
|
if style == "categories_and_latest_topics".freeze
|
||||||
@topic_list = TopicQuery.new(current_user, topic_options).list_latest
|
@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
|
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 = 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
|
end
|
||||||
|
|
||||||
if @topic_list.present?
|
if @topic_list.present? && @topic_list.topics.present?
|
||||||
store_preloaded(
|
store_preloaded(
|
||||||
@topic_list.preload_key,
|
@topic_list.preload_key,
|
||||||
MultiJson.dump(TopicListSerializer.new(@topic_list, scope: guardian))
|
MultiJson.dump(TopicListSerializer.new(@topic_list, scope: guardian))
|
||||||
|
@ -401,7 +401,7 @@ class TopicQuery
|
|||||||
end
|
end
|
||||||
|
|
||||||
list = TopicList.new(filter, @user, topics, options.merge(@options))
|
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
|
list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,6 +26,13 @@ describe CategoriesController do
|
|||||||
expect(html.css('body.crawler')).to be_present
|
expect(html.css('body.crawler')).to be_present
|
||||||
expect(html.css("a[href=\"/forum/c/#{category.slug}\"]")).to be_present
|
expect(html.css("a[href=\"/forum/c/#{category.slug}\"]")).to be_present
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'extensibility event' do
|
context 'extensibility event' do
|
||||||
|
Reference in New Issue
Block a user