FIX: various fixes to draft system

- destroyDraft which is called when we cancel a draft is now async,
  removing race conditions when you click "reply" to a post and are
  already editing. We used to trigger double dialogs for cancelling
  drafts which was confusing.

- Remove reply as new topic / reply as pm keys, they are no longer
  used and only caused confustion. For example we used to pop up a
  warning when you are composing a reply and flick to reply as
  new topic

- Remove createTopic key, this was a bug that proliferated. Whenever
  creating a topic via the C shortcut or clicking on new topic on full
  screen search the correct new topic draft key will be used
  consistently

- When abandoning an edit we now say "Are you sure you want to discard
  your changes" (instead of abandon your post which is confusing)
This commit is contained in:
Sam Saffron
2019-10-21 08:57:55 +11:00
parent 858cf5836c
commit 98d6cee7c7
11 changed files with 85 additions and 84 deletions

View File

@ -5,8 +5,7 @@ import {
CREATE_TOPIC,
CREATE_SHARED_DRAFT,
REPLY,
EDIT,
NEW_PRIVATE_MESSAGE_KEY
EDIT
} from "discourse/models/composer";
// Component can get destroyed and lose state
@ -209,7 +208,6 @@ export default DropdownSelectBoxComponent.extend({
_replyFromExisting(options, post, topic) {
this.closeComposer();
this.openComposer(options, post, topic);
},
@ -244,6 +242,7 @@ export default DropdownSelectBoxComponent.extend({
options.action = CREATE_TOPIC;
options.categoryId = this.get("composerModel.topic.category.id");
options.disableScopedCategory = true;
options.skipDraftCheck = true;
this._replyFromExisting(options, _postSnapshot, _topicSnapshot);
},
@ -269,7 +268,7 @@ export default DropdownSelectBoxComponent.extend({
options.action = PRIVATE_MESSAGE;
options.usernames = usernames;
options.archetypeId = "private_message";
options.draftKey = NEW_PRIVATE_MESSAGE_KEY;
options.skipDraftCheck = true;
this._replyFromExisting(options, _postSnapshot, _topicSnapshot);
},