1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 16:36:47 +02:00

Allow inter-discussion replying

This commit is contained in:
Toby Zerner
2015-08-06 13:17:21 +09:30
parent e82a50c5d7
commit c014c330d9
5 changed files with 34 additions and 31 deletions

View File

@@ -107,7 +107,7 @@ export default function addComposerAutocomplete() {
.forEach(post => {
const user = post.user();
suggestions.push(
makeSuggestion(user, '@' + user.username() + '#' + post.number(), [
makeSuggestion(user, '@' + user.username() + '#' + post.id(), [
app.trans('mentions.reply_to_post', {number: post.number()}), ' — ',
truncate(post.contentPlain(), 200)
], 'MentionsDropdown-post')

View File

@@ -7,11 +7,11 @@ export default function addPostMentionPreviews() {
extend(CommentPost.prototype, 'config', function() {
const contentHtml = this.props.post.contentHtml();
if (contentHtml === this.oldPostContentHtml) return;
if (contentHtml === this.oldPostContentHtml || this.isEditing()) return;
this.oldPostContentHtml = contentHtml;
const discussion = this.props.post.discussion();
const parentPost = this.props.post;
this.$('.UserMention, .PostMention').each(function() {
m.route.call(this, this, false, {}, {attrs: {href: this.getAttribute('href')}});
@@ -19,7 +19,7 @@ export default function addPostMentionPreviews() {
this.$('.PostMention').each(function() {
const $this = $(this);
const number = $this.data('number');
const id = $this.data('id');
let timeout;
// Wrap the mention link in a wrapper element so that we can insert a
@@ -29,7 +29,7 @@ export default function addPostMentionPreviews() {
$this.wrap($wrapper).after($preview);
const getPostElement = () => {
return $(`.PostStream-item[data-number="${number}"]`);
return $(`.PostStream-item[data-id="${id}"]`);
};
const showPreview = () => {
@@ -57,18 +57,23 @@ export default function addPostMentionPreviews() {
};
const showPost = post => {
m.render($preview[0], <li>{PostPreview.component({post})}</li>);
const discussion = post.discussion();
m.render($preview[0], [
discussion !== parentPost.discussion()
? <li><span className="PostMention-preview-discussion">{discussion.title()}</span></li>
: '',
<li>{PostPreview.component({post})}</li>
]);
positionPreview();
};
const post = discussion.posts().filter(p => p && p.number() === number)[0];
const post = app.store.getById('posts', id);
if (post) {
showPost(post);
} else {
m.render($preview[0], LoadingIndicator.component());
app.store.find('posts', {
filter: {discussion: discussion.id(), number}
}).then(posts => showPost(posts[0]));
app.store.find('posts', id).then(showPost);
positionPreview();
}

View File

@@ -10,7 +10,7 @@ export default function() {
if (post.isHidden() || (app.session.user && !post.discussion().canReply())) return;
function insertMention(component, quote) {
const mention = '@' + post.user().username() + '#' + post.number() + ' ';
const mention = '@' + post.user().username() + '#' + post.id() + ' ';
// If the composer is empty, then assume we're starting a new reply.
// In which case we don't want the user to have to confirm if they