FIX: Make sure tag-based topic list uses its own preload key (#12354)
When transitioning from a tag topic list e.g. /tag/alerts
to the / route the topic list was not reloaded because the
same preload key was used for both lists (topic_list_latest).
The topic list was only reloaded when clicking on the / route
a second time because then it is forced to reload.
In the topic list adapter, we call `PreloadStore.getAndRemove` to
get the topic lists:
534777f5fd/app/assets/javascripts/discourse/app/adapters/topic-list.js (L34-L41)
Now instead of both / and /tag/alerts sharing the same preload
key of `topic_list_latest`, the tag has a key of `topic_list_tag/alerts/l/latest`
This commit is contained in:
parent
be6864e44c
commit
cf1a80dea6
|
@ -69,6 +69,9 @@ class TopicList < DraftableList
|
|||
else
|
||||
"topic_list_#{@category.url.sub(/^\//, '')}/l/#{@filter}"
|
||||
end
|
||||
elsif @tags
|
||||
tag = @tags.first
|
||||
"topic_list_tag/#{tag.name}/l/#{@filter}"
|
||||
else
|
||||
"topic_list_#{@filter}"
|
||||
end
|
||||
|
|
|
@ -93,6 +93,7 @@ describe TopicList do
|
|||
|
||||
describe "#preload_key" do
|
||||
let(:category) { Fabricate(:category) }
|
||||
let(:tag) { Fabricate(:tag) }
|
||||
|
||||
it "generates correct key for categories" do
|
||||
topic_list = TopicList.new('latest', nil, nil, category: category, category_id: category.id)
|
||||
|
@ -103,5 +104,10 @@ describe TopicList do
|
|||
topic_list = TopicList.new('latest', nil, nil, category: category, category_id: category.id, no_subcategories: true)
|
||||
expect(topic_list.preload_key).to eq("topic_list_c/#{category.slug}/#{category.id}/none/l/latest")
|
||||
end
|
||||
|
||||
it "generates correct key for tag" do
|
||||
topic_list = TopicList.new('latest', nil, nil, tags: [tag])
|
||||
expect(topic_list.preload_key).to eq("topic_list_tag/#{tag.name}/l/latest")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue