mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 09:33:44 +08:00
FIX: when replying to a expanded reply, correctly attribute author
This commit is contained in:
parent
80893a69ba
commit
d7f2933743
|
@ -43,8 +43,7 @@ export default Ember.Controller.extend({
|
||||||
if (this.get('buffer') === selectedText) return;
|
if (this.get('buffer') === selectedText) return;
|
||||||
|
|
||||||
// we need to retrieve the post data from the posts collection in the topic controller
|
// we need to retrieve the post data from the posts collection in the topic controller
|
||||||
const postStream = this.get('controllers.topic.model.postStream');
|
this.set('postId', postId);
|
||||||
this.set('post', postStream.findLoadedPost(postId));
|
|
||||||
this.set('buffer', selectedText);
|
this.set('buffer', selectedText);
|
||||||
|
|
||||||
// create a marker element
|
// create a marker element
|
||||||
|
@ -87,7 +86,17 @@ export default Ember.Controller.extend({
|
||||||
|
|
||||||
quoteText() {
|
quoteText() {
|
||||||
|
|
||||||
const post = this.get('post');
|
const postStream = this.get('controllers.topic.model.postStream');
|
||||||
|
const postId = this.get('postId');
|
||||||
|
const post = postStream.findLoadedPost(postId);
|
||||||
|
|
||||||
|
// defer load if needed, if in an expanded replies section
|
||||||
|
if (!post) {
|
||||||
|
postStream.loadPost(postId).then(() => {
|
||||||
|
this.quoteText();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If we can't create a post, delegate to reply as new topic
|
// If we can't create a post, delegate to reply as new topic
|
||||||
if (!this.get('controllers.topic.model.details.can_create_post')) {
|
if (!this.get('controllers.topic.model.details.can_create_post')) {
|
||||||
|
@ -98,7 +107,7 @@ export default Ember.Controller.extend({
|
||||||
const composerController = this.get('controllers.composer');
|
const composerController = this.get('controllers.composer');
|
||||||
const composerOpts = {
|
const composerOpts = {
|
||||||
action: Discourse.Composer.REPLY,
|
action: Discourse.Composer.REPLY,
|
||||||
draftKey: this.get('post.topic.draft_key')
|
draftKey: post.get('topic.draft_key')
|
||||||
};
|
};
|
||||||
|
|
||||||
if(post.get('post_number') === 1) {
|
if(post.get('post_number') === 1) {
|
||||||
|
|
|
@ -441,6 +441,14 @@ const PostStream = RestModel.extend({
|
||||||
return this.get('postIdentityMap').get(id);
|
return this.get('postIdentityMap').get(id);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadPost(postId){
|
||||||
|
const url = "/posts/" + postId;
|
||||||
|
const store = this.store;
|
||||||
|
|
||||||
|
return Discourse.ajax(url).then((p) =>
|
||||||
|
this.storePost(store.createRecord('post', p)));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Finds and adds a post to the stream by id. Typically this would happen if we receive a message
|
Finds and adds a post to the stream by id. Typically this would happen if we receive a message
|
||||||
from the message bus indicating there's a new post. We'll only insert it if we currently
|
from the message bus indicating there's a new post. We'll only insert it if we currently
|
||||||
|
|
|
@ -3,6 +3,8 @@ import ScreenTrack from 'discourse/lib/screen-track';
|
||||||
export default Discourse.GroupedView.extend({
|
export default Discourse.GroupedView.extend({
|
||||||
templateName: 'embedded-post',
|
templateName: 'embedded-post',
|
||||||
classNames: ['reply'],
|
classNames: ['reply'],
|
||||||
|
attributeBindings: ['data-post-id'],
|
||||||
|
'data-post-id': Em.computed.alias('content.id'),
|
||||||
|
|
||||||
_startTracking: function() {
|
_startTracking: function() {
|
||||||
const post = this.get('content');
|
const post = this.get('content');
|
||||||
|
|
|
@ -78,7 +78,7 @@ export default Ember.View.extend({
|
||||||
// breaks if quoting has been disabled by the user
|
// breaks if quoting has been disabled by the user
|
||||||
if (!Discourse.User.currentProp('enable_quoting')) return;
|
if (!Discourse.User.currentProp('enable_quoting')) return;
|
||||||
// retrieve the post id from the DOM
|
// retrieve the post id from the DOM
|
||||||
const postId = $target.closest('.boxed').data('post-id');
|
const postId = $target.closest('.boxed, .reply').data('post-id');
|
||||||
// select the text
|
// select the text
|
||||||
if (postId) controller.selectText(postId);
|
if (postId) controller.selectText(postId);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user