mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 22:13:45 +08:00
amend preloader api to supply topic list
This commit is contained in:
parent
2c59ffeb2c
commit
9c51e3e8e7
|
@ -19,9 +19,9 @@ class TopicList
|
|||
end
|
||||
end
|
||||
|
||||
def self.preload(topics)
|
||||
def self.preload(topics, object)
|
||||
if @preload
|
||||
@preload.each{|preload| preload.call(topics)}
|
||||
@preload.each{|preload| preload.call(topics, object)}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,8 @@ class TopicList
|
|||
:filter,
|
||||
:for_period,
|
||||
:per_page,
|
||||
:tags
|
||||
:tags,
|
||||
:current_user
|
||||
|
||||
def initialize(filter, current_user, topics, opts=nil)
|
||||
@filter = filter
|
||||
|
@ -116,7 +117,7 @@ class TopicList
|
|||
Topic.preload_custom_fields(@topics, preloaded_custom_fields)
|
||||
end
|
||||
|
||||
TopicList.preload(@topics)
|
||||
TopicList.preload(@topics, self)
|
||||
|
||||
@topics
|
||||
end
|
||||
|
|
|
@ -31,7 +31,8 @@ describe TopicList do
|
|||
context "preload" do
|
||||
it "allows preloading of data" do
|
||||
preloaded_topic = false
|
||||
preloader = lambda do |topics|
|
||||
preloader = lambda do |topics, topic_list|
|
||||
expect(TopicList === topic_list).to eq(true)
|
||||
expect(topics.length).to eq(1)
|
||||
preloaded_topic = true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user