0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-05 16:23:34 +08:00
discourse/config/initializers/300-nested-replies.rb
Mark VanLandingham 2409dc314a
FEATURE: Add nested replies category conversion (#41236)
At the moment there is no way in the UI to convert a category to nested
replies. This introduces a backfill button and UI to show admin the
current state (using category custom field). Screenshots pretty much
tell the story:

<img width="1483" height="1187" alt="Screenshot 2026-07-02 at 10 08
23 AM"
src="https://github.com/user-attachments/assets/532bd7d2-8aae-455a-9744-aee0f3ac5b82"
/>
<img width="1498" height="1247" alt="Screenshot 2026-07-02 at 10 08
38 AM"
src="https://github.com/user-attachments/assets/a1382732-8b72-4526-a770-72b6452b56bb"
/>
<img width="1460" height="1220" alt="Screenshot 2026-07-02 at 10 08
58 AM"
src="https://github.com/user-attachments/assets/b4113347-c760-4f66-b947-988c270750a6"
/>
2026-07-06 08:22:22 -05:00

16 lines
480 B
Ruby
Vendored

# frozen_string_literal: true
Rails.application.config.to_prepare do
require "nested_replies"
Category.register_custom_field_type(NestedReplies::CONVERSION_COMPLETED_CUSTOM_FIELD, :boolean)
end
DiscourseEvent.on(:topic_created) do |topic, _opts, _user|
next unless SiteSetting.nested_replies_enabled
next unless topic.regular?
if SiteSetting.nested_replies_default || topic.category&.nested_replies_default
NestedTopic.find_or_create_by!(topic: topic)
end
end