Skip to content

A platform for community discussion. Free, open, simple.

FIX: Don't set `categoryId` on PM drafts (#20475)

Jarek Radosz7c74e4882a59
diff --git a/app/assets/javascripts/discourse/app/models/composer.js b/app/assets/javascripts/discourse/app/models/composer.js
index 267c2412d4f..8340083a0e7 100644
--- a/app/assets/javascripts/discourse/app/models/composer.js
+++ b/app/assets/javascripts/discourse/app/models/composer.js
@@ -142,7 +142,9 @@ const Composer = RestModel.extend({
set(categoryId) {
const oldCategoryId = this._categoryId;
- if (isEmpty(categoryId)) {
+ if (this.privateMessage) {
+ categoryId = null;
+ } else if (isEmpty(categoryId)) {
// Check if there is a default composer category to set
const defaultComposerCategoryId = parseInt(
this.siteSettings.default_composer_category,
diff --git a/app/assets/javascripts/discourse/tests/unit/models/composer-test.js b/app/assets/javascripts/discourse/tests/unit/models/composer-test.js
index b671ce5dd4a..9306c8554ef 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/composer-test.js
@@ -317,6 +317,20 @@ module("Unit | Model | composer", function (hooks) {
);
});
+ test("initial category when creating PM and there is a default composer category", function (assert) {
+ this.siteSettings.default_composer_category = 2;
+ const composer = openComposer.call(this, {
+ action: PRIVATE_MESSAGE,
+ draftKey: "abcd",
+ draftSequence: 1,
+ });
+ assert.strictEqual(
+ composer.categoryId,
+ null,
+ "it doesn't save the category"
+ );
+ });
+
test("open with a quote", function (assert) {
const quote =
'[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]';