2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-08 16:44:27 -05:00
|
|
|
# Helps us respond with a topic list from a controller
|
|
|
|
module TopicListResponder
|
|
|
|
|
|
|
|
def respond_with_list(list)
|
|
|
|
discourse_expires_in 1.minute
|
|
|
|
|
|
|
|
list.draft_key = Draft::NEW_TOPIC
|
2020-05-14 21:14:20 -04:00
|
|
|
list.draft_sequence = DraftSequence.current(current_user, Draft::NEW_TOPIC)
|
|
|
|
list.draft = Draft.get(current_user, list.draft_key, list.draft_sequence) if current_user
|
2015-01-08 16:44:27 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
@list = list
|
|
|
|
store_preloaded(list.preload_key, MultiJson.dump(TopicListSerializer.new(list, scope: guardian)))
|
2015-02-12 11:53:21 -05:00
|
|
|
render 'list/list'
|
2015-01-08 16:44:27 -05:00
|
|
|
end
|
|
|
|
format.json do
|
|
|
|
render_serialized(list, TopicListSerializer)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|