Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2c79611

Browse files
authored
Merge pull request #2023 from github/fixes/2022-inline-comment-bugs
Fixing inline comment bugs
2 parents 00765c6 + 78a4ad7 commit 2c79611

File tree

5 files changed

+5
-10
lines changed

5 files changed

+5
-10
lines changed

src/GitHub.App/ViewModels/PullRequestReviewCommentThreadViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public bool IsNewThread
7878
public async Task InitializeAsync(
7979
IPullRequestSession session,
8080
IPullRequestSessionFile file,
81-
PullRequestReviewModel review,
8281
IInlineCommentThreadModel thread,
8382
bool addPlaceholder)
8483
{
@@ -97,7 +96,7 @@ public async Task InitializeAsync(
9796
await vm.InitializeAsync(
9897
session,
9998
this,
100-
review,
99+
comment.Review,
101100
comment.Comment,
102101
CommentEditState.None).ConfigureAwait(false);
103102
Comments.Add(vm);
@@ -110,7 +109,7 @@ await vm.InitializeAsync(
110109
await vm.InitializeAsPlaceholderAsync(
111110
session,
112111
this,
113-
review.State == PullRequestReviewState.Pending,
112+
session.HasPendingReview,
114113
false).ConfigureAwait(true);
115114

116115
var (key, secondaryKey) = GetDraftKeys(vm);

src/GitHub.Exports.Reactive/ViewModels/IPullRequestReviewCommentThreadViewModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ public interface IPullRequestReviewCommentThreadViewModel : ICommentThreadViewMo
4646
/// </summary>
4747
/// <param name="session">The pull request session.</param>
4848
/// <param name="file">The file that the comment is on.</param>
49-
/// <param name="review">The associated review.</param>
5049
/// <param name="thread">The thread.</param>
5150
/// <param name="addPlaceholder">
5251
/// Whether to add a placeholder comment at the end of the thread.
5352
/// </param>
5453
Task InitializeAsync(
5554
IPullRequestSession session,
5655
IPullRequestSessionFile file,
57-
PullRequestReviewModel review,
5856
IInlineCommentThreadModel thread,
5957
bool addPlaceholder);
6058

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ static void BuildPullRequestThreads(PullRequestDetailModel model)
845845
}
846846

847847
// Get the comments that are replies and place them into the relevant list.
848-
foreach (CommentAdapter comment in model.Reviews.SelectMany(x => x.Comments))
848+
foreach (CommentAdapter comment in model.Reviews.SelectMany(x => x.Comments).OrderBy(x => x.CreatedAt))
849849
{
850850
if (comment.ReplyTo != null)
851851
{

src/GitHub.InlineReviews/ViewModels/InlineCommentPeekViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async Task UpdateThread()
181181

182182
if (thread?.Comments.Count > 0)
183183
{
184-
await vm.InitializeAsync(session, file, thread.Comments[0].Review, thread, true);
184+
await vm.InitializeAsync(session, file, thread, true);
185185
}
186186
else
187187
{

test/GitHub.App.UnitTests/ViewModels/PullRequestReviewCommentThreadViewModelTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,13 @@ async Task<PullRequestReviewCommentThreadViewModel> CreateTarget(
111111
IViewViewModelFactory factory = null,
112112
IPullRequestSession session = null,
113113
IPullRequestSessionFile file = null,
114-
PullRequestReviewModel review = null,
115114
IEnumerable<InlineCommentModel> comments = null,
116115
bool newThread = false)
117116
{
118117
draftStore = draftStore ?? Substitute.For<IMessageDraftStore>();
119118
factory = factory ?? CreateFactory();
120119
session = session ?? CreateSession();
121120
file = file ?? CreateFile();
122-
review = review ?? new PullRequestReviewModel();
123121
comments = comments ?? CreateComments();
124122

125123
var result = new PullRequestReviewCommentThreadViewModel(draftStore, factory);
@@ -134,7 +132,7 @@ async Task<PullRequestReviewCommentThreadViewModel> CreateTarget(
134132
thread.Comments.Returns(comments.ToList());
135133
thread.LineNumber.Returns(10);
136134

137-
await result.InitializeAsync(session, file, review, thread, true);
135+
await result.InitializeAsync(session, file, thread, true);
138136
}
139137

140138
return result;

0 commit comments

Comments
 (0)