FIX: resume editing when through /new-message (#29637)

"Resume editing" would do nothing when going through the `/new-message` flow.

This seems to be broken since [this commit](b0f6d074be). which moved `this._setModel` calls around – the same we're doing now, but to different places: the first one needs to happen after the `draft.data` has been set , while the second needs to happen before the `this.open` call.
This commit is contained in:
Renato Atilio 2024-11-07 17:39:58 -03:00 committed by GitHub
parent 4840060568
commit 7568e732cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 2 deletions

View File

@ -1407,8 +1407,6 @@ export default class ComposerService extends Service {
composerModel.setProperties({ unlistTopic: false, whisper: false }); composerModel.setProperties({ unlistTopic: false, whisper: false });
} }
await this._setModel(composerModel, opts);
// we need a draft sequence for the composer to work // we need a draft sequence for the composer to work
if (opts.draftSequence === undefined) { if (opts.draftSequence === undefined) {
let data = await Draft.get(opts.draftKey); let data = await Draft.get(opts.draftKey);
@ -1421,9 +1419,14 @@ export default class ComposerService extends Service {
opts.draft ||= data.draft; opts.draft ||= data.draft;
opts.draftSequence = data.draft_sequence; opts.draftSequence = data.draft_sequence;
await this._setModel(composerModel, opts);
return; return;
} }
await this._setModel(composerModel, opts);
// otherwise, do the draft check async // otherwise, do the draft check async
if (!opts.draft && !opts.skipDraftCheck) { if (!opts.draft && !opts.skipDraftCheck) {
let data = await Draft.get(opts.draftKey); let data = await Draft.get(opts.draftKey);

View File

@ -94,5 +94,24 @@ describe "Composer - discard draft modal", type: :system do
wait_for(timeout: 5) { Draft.find_by(draft_key: draft_key) == nil } wait_for(timeout: 5) { Draft.find_by(draft_key: draft_key) == nil }
end end
it "resumes draft when using /new-message" do
visit "/new-message"
composer.fill_content("a b c d e f g")
composer.close
expect(discard_draft_modal).to be_open
discard_draft_modal.click_save
visit "/new-message"
expect(dialog).to be_open
expect(page).to have_content(I18n.t("js.drafts.abandon.confirm"))
dialog.click_button I18n.t("js.drafts.abandon.no_value")
expect(composer).to be_opened
expect(composer).to have_content("a b c d e f g")
end
end end
end end