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

This commit is contained in:
Jarek Radosz 2023-03-01 11:32:12 +01:00 committed by GitHub
parent ddbe6cf3b5
commit 7c74e4882a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -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,

View File

@ -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]';