UX: improve handling of PM drafts
- Show PM draft if it exists on any of the your user tabs - If a draft is already open when visiting user profile suppress loading of draft
This commit is contained in:
parent
1ad3340325
commit
e805dd7000
|
@ -473,6 +473,12 @@ export default Ember.Controller.extend({
|
|||
alert("composer was opened without a draft key");
|
||||
throw "composer opened without a proper draft key";
|
||||
}
|
||||
const self = this;
|
||||
let composerModel = this.get('model');
|
||||
|
||||
if (opts.ignoreIfChanged && composerModel && composerModel.composeState !== Composer.CLOSED) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we show the subcategory list, scope the categories drop down to
|
||||
// the category we opened the composer with.
|
||||
|
@ -480,8 +486,6 @@ export default Ember.Controller.extend({
|
|||
this.set('scopedCategoryId', opts.categoryId);
|
||||
}
|
||||
|
||||
const self = this;
|
||||
let composerModel = this.get('model');
|
||||
|
||||
this.setProperties({ showEditReason: false, editReason: null });
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import Draft from 'discourse/models/draft';
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
|
||||
renderTemplate() {
|
||||
|
@ -11,25 +9,6 @@ export default Discourse.Route.extend({
|
|||
return this.modelFor("user");
|
||||
},
|
||||
|
||||
setupController(controller, user) {
|
||||
this._super();
|
||||
// Bring up a draft
|
||||
const composerController = this.controllerFor("composer");
|
||||
controller.set("model", user);
|
||||
if (this.currentUser) {
|
||||
Draft.get("new_private_message").then(function(data) {
|
||||
if (data.draft) {
|
||||
composerController.open({
|
||||
draft: data.draft,
|
||||
draftKey: "new_private_message",
|
||||
ignoreIfChanged: true,
|
||||
draftSequence: data.draft_sequence
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition: function() {
|
||||
this._super();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
const INDEX_STREAM_ROUTES = ["user.deletedPosts", "user.flaggedPosts", "userActivity.index"];
|
||||
|
||||
import Draft from 'discourse/models/draft';
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
|
||||
titleToken() {
|
||||
|
@ -55,6 +57,21 @@ export default Discourse.Route.extend({
|
|||
setupController(controller, user) {
|
||||
controller.set('model', user);
|
||||
this.searchService.set('searchContext', user.get('searchContext'));
|
||||
|
||||
const composerController = this.controllerFor("composer");
|
||||
controller.set("model", user);
|
||||
if (this.currentUser) {
|
||||
Draft.get("new_private_message").then(function(data) {
|
||||
if (data.draft) {
|
||||
composerController.open({
|
||||
draft: data.draft,
|
||||
draftKey: "new_private_message",
|
||||
ignoreIfChanged: true,
|
||||
draftSequence: data.draft_sequence
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
activate() {
|
||||
|
|
Loading…
Reference in New Issue