mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing position for new comments
--HG-- branch : 1.x
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Orchard.Comments.Controllers {
|
||||
var commentPart = comment.As<CommentPart>();
|
||||
|
||||
// ensure the comments are not closed on the container, as the html could have been tampered manually
|
||||
var container = Services.ContentManager.Get(commentPart.CommentedOnContainer);
|
||||
var container = Services.ContentManager.Get(commentPart.CommentedOn);
|
||||
CommentsPart commentsPart = null;
|
||||
if(container != null) {
|
||||
commentsPart = container.As<CommentsPart>();
|
||||
@@ -63,16 +63,16 @@ namespace Orchard.Comments.Controllers {
|
||||
// what is the next position after the anwered comment
|
||||
if(repliedPart != null) {
|
||||
// the next comment is the one right after the RepliedOn one, at the same level
|
||||
var nextComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOnContainer)
|
||||
var nextComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOn)
|
||||
.Where(x => x.RepliedOn == repliedPart.RepliedOn && x.CommentDateUtc > repliedPart.CommentDateUtc)
|
||||
.OrderBy(x => x.CommentDateUtc)
|
||||
.OrderBy(x => x.Position)
|
||||
.Slice(0, 1)
|
||||
.FirstOrDefault();
|
||||
|
||||
// the previous comment is the last one under the RepliedOn
|
||||
var previousComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOnContainer)
|
||||
var previousComment = _commentService.GetCommentsForCommentedContent(commentPart.CommentedOn)
|
||||
.Where(x => x.RepliedOn == commentPart.RepliedOn)
|
||||
.OrderByDescending(x => x.CommentDateUtc)
|
||||
.OrderByDescending(x => x.Position)
|
||||
.Slice(0, 1)
|
||||
.FirstOrDefault();
|
||||
|
||||
@@ -92,7 +92,9 @@ namespace Orchard.Comments.Controllers {
|
||||
|
||||
}
|
||||
else {
|
||||
// new comment, last in position
|
||||
commentPart.RepliedOn = null;
|
||||
commentPart.Position = comment.Id;
|
||||
}
|
||||
|
||||
if (commentPart.Status == CommentStatus.Pending) {
|
||||
|
Reference in New Issue
Block a user