FEATURE: Multiple Draft Topics (#30790)

Allows users to save multiple topic and personal message drafts,
allowing more flexibility around content creation.

The "New Topic" button will now always start a fresh topic. Drafts can
be resumed from the drafts dropdown menu or using the "My Drafts" link
in the sidebar.

Since drafts require a unique `draft_key` and `user_id` combination, we
have updated the format of the draft key for both topics and personal
messages. They will now have a prefix like "new_topic_" or
"new_message_" with the timestamp of when the composer was first opened
appended.
This commit is contained in:
David Battersby
2025-01-29 10:23:26 +04:00
committed by GitHub
parent 29e48a6478
commit c64b5d6d7a
25 changed files with 132 additions and 275 deletions

View File

@ -128,28 +128,6 @@ RSpec.describe CurrentUserSerializer do
end
end
describe "#has_topic_draft" do
it "is not included by default" do
payload = serializer.as_json
expect(payload).not_to have_key(:has_topic_draft)
end
it "returns true when user has a draft" do
Draft.set(user, Draft::NEW_TOPIC, 0, "test1")
payload = serializer.as_json
expect(payload[:has_topic_draft]).to eq(true)
end
it "clearing a draft removes has_topic_draft from payload" do
sequence = Draft.set(user, Draft::NEW_TOPIC, 0, "test1")
Draft.clear(user, Draft::NEW_TOPIC, sequence)
payload = serializer.as_json
expect(payload).not_to have_key(:has_topic_draft)
end
end
describe "#can_ignore_users" do
let(:guardian) { Guardian.new(user) }
let(:payload) { serializer.as_json }