discourse/lib/topic_list_responder.rb
Guo Xiang Tan b979579c1b
DEV: Refactor draft attributes for CategoryList and TopicList.
Avoid repeating the same logic in a bunch of places which will allow us
to make changes to the draft attributes easier in the future.
2020-07-24 10:11:30 +08:00

22 lines
493 B
Ruby

# frozen_string_literal: true
# Helps us respond with a topic list from a controller
module TopicListResponder
def respond_with_list(list)
discourse_expires_in 1.minute
respond_to do |format|
format.html do
@list = list
store_preloaded(list.preload_key, MultiJson.dump(TopicListSerializer.new(list, scope: guardian)))
render 'list/list'
end
format.json do
render_serialized(list, TopicListSerializer)
end
end
end
end