mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -473,6 +473,12 @@ export default Ember.Controller.extend({
|
|||||||
alert("composer was opened without a draft key");
|
alert("composer was opened without a draft key");
|
||||||
throw "composer opened without a proper 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
|
// If we show the subcategory list, scope the categories drop down to
|
||||||
// the category we opened the composer with.
|
// the category we opened the composer with.
|
||||||
@@ -480,8 +486,6 @@ export default Ember.Controller.extend({
|
|||||||
this.set('scopedCategoryId', opts.categoryId);
|
this.set('scopedCategoryId', opts.categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const self = this;
|
|
||||||
let composerModel = this.get('model');
|
|
||||||
|
|
||||||
this.setProperties({ showEditReason: false, editReason: null });
|
this.setProperties({ showEditReason: false, editReason: null });
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import Draft from 'discourse/models/draft';
|
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
|
|
||||||
renderTemplate() {
|
renderTemplate() {
|
||||||
@@ -11,25 +9,6 @@ export default Discourse.Route.extend({
|
|||||||
return this.modelFor("user");
|
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: {
|
actions: {
|
||||||
willTransition: function() {
|
willTransition: function() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const INDEX_STREAM_ROUTES = ["user.deletedPosts", "user.flaggedPosts", "userActivity.index"];
|
const INDEX_STREAM_ROUTES = ["user.deletedPosts", "user.flaggedPosts", "userActivity.index"];
|
||||||
|
|
||||||
|
import Draft from 'discourse/models/draft';
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
|
|
||||||
titleToken() {
|
titleToken() {
|
||||||
@@ -55,6 +57,21 @@ export default Discourse.Route.extend({
|
|||||||
setupController(controller, user) {
|
setupController(controller, user) {
|
||||||
controller.set('model', user);
|
controller.set('model', user);
|
||||||
this.searchService.set('searchContext', user.get('searchContext'));
|
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() {
|
activate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user