mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Load categories with user activity and drafts (#26553)
When lazy load categories is enabled, categories should be loaded with user activity items and drafts because the categories may not be preloaded on the client side.
This commit is contained in:
@ -17,7 +17,15 @@ class DraftsController < ApplicationController
|
||||
limit: fetch_limit_from_params(default: nil, max: INDEX_LIMIT),
|
||||
)
|
||||
|
||||
render json: { drafts: stream ? serialize_data(stream, DraftSerializer) : [] }
|
||||
response = { drafts: serialize_data(stream, DraftSerializer) }
|
||||
|
||||
if guardian.can_lazy_load_categories?
|
||||
category_ids = stream.map { |draft| draft.topic&.category_id }.compact.uniq
|
||||
categories = Category.secured(guardian).with_parents(category_ids)
|
||||
response[:categories] = serialize_data(categories, CategoryBadgeSerializer)
|
||||
end
|
||||
|
||||
render json: response
|
||||
end
|
||||
|
||||
def show
|
||||
|
Reference in New Issue
Block a user