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

Commit fe4d63b

Browse files
Merge branch 'features/check-suite-annotations' into features/check-suite-annotations-inline
# Conflicts: # src/GitHub.App/SampleData/PullRequestAnnotationItemViewModelDesigner.cs # src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationItemViewModel.cs # src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationsViewModel.cs
2 parents 0708f8d + d608dac commit fe4d63b

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationItemViewModel.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,27 @@ public class PullRequestAnnotationItemViewModel : ViewModelBase, IPullRequestAnn
2222
/// <summary>
2323
/// Initializes the <see cref="PullRequestAnnotationItemViewModel"/>.
2424
/// </summary>
25+
/// <param name="annotation">The check run annotation model.</param>
26+
/// <param name="isFileInPullRequest">A flag that denotes if the annotation is part of the pull request's changes.</param>
2527
/// <param name="checkSuite">The check suite model.</param>
2628
/// <param name="checkRun">The check run model.</param>
2729
/// <param name="annotation">The check run annotation model.</param>
2830
/// <param name="session">The pull request session.</param>
2931
/// <param name="editorService">The pull request editor service.</param>
30-
public PullRequestAnnotationItemViewModel(CheckSuiteModel checkSuite,
32+
public PullRequestAnnotationItemViewModel(
33+
CheckRunAnnotationModel annotation,
34+
bool isFileInPullRequest,
3135
CheckRunModel checkRun,
32-
CheckRunAnnotationModel annotation,
36+
CheckSuiteModel checkSuite,
3337
IPullRequestSession session,
3438
IPullRequestEditorService editorService)
3539
{
3640
this.checkSuite = checkSuite;
3741
this.checkRun = checkRun;
3842
this.session = session;
3943
this.editorService = editorService;
40-
this.Annotation = annotation;
41-
42-
IsFileInPullRequest = session.PullRequest.ChangedFiles.Any(model => model.FileName == annotation.Path);
44+
Annotation = annotation;
45+
IsFileInPullRequest = isFileInPullRequest;
4346

4447
OpenAnnotation = ReactiveCommand.CreateFromTask<Unit>(
4548
async _ => await editorService.OpenDiff(session, annotation.Path, checkSuite.HeadSha, annotation.EndLine - 1),

src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationsViewModel.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,20 @@ void Load(PullRequestDetailModel pullRequest)
127127
CheckSuiteName = checkSuiteRun.checkSuite.ApplicationName;
128128
CheckRunName = checkSuiteRun.checkRun.Name;
129129

130-
AnnotationsDictionary = checkSuiteRun.checkRun.Annotations
131-
.GroupBy(annotation => annotation.Path)
130+
// .Select(annotation => new PullRequestAnnotationItemViewModel(checkSuiteRun.checkSuite, checkSuiteRun.checkRun, annotation, session, pullRequestEditorService))
131+
132+
var changedFiles = new HashSet<string>(session.PullRequest.ChangedFiles.Select(model => model.FileName));
133+
134+
var annotationsLookup = checkSuiteRun.checkRun.Annotations
135+
.ToLookup(annotation => annotation.Path);
136+
137+
AnnotationsDictionary = annotationsLookup
138+
.Select(models => models.Key)
139+
.OrderBy(s => s)
132140
.ToDictionary(
133-
grouping => grouping.Key,
134-
grouping => grouping
135-
.Select(annotation => new PullRequestAnnotationItemViewModel(checkSuiteRun.checkSuite, checkSuiteRun.checkRun, annotation, session, pullRequestEditorService))
141+
path => path,
142+
path => annotationsLookup[path]
143+
.Select(annotation => new PullRequestAnnotationItemViewModel(annotation, changedFiles.Contains(path)))
136144
.Cast<IPullRequestAnnotationItemViewModel>()
137145
.ToArray()
138146
);
@@ -142,6 +150,5 @@ void Load(PullRequestDetailModel pullRequest)
142150
IsBusy = false;
143151
}
144152
}
145-
146153
}
147154
}

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Text;
99
using System.Threading.Tasks;
1010
using GitHub.Api;
11-
using GitHub.App.Services;
1211
using GitHub.Factories;
1312
using GitHub.InlineReviews.Models;
1413
using GitHub.Models;
@@ -18,22 +17,15 @@
1817
using LibGit2Sharp;
1918
using Microsoft.VisualStudio.Text;
2019
using Microsoft.VisualStudio.Text.Projection;
21-
using Octokit;
2220
using Octokit.GraphQL;
23-
using Octokit.GraphQL.Core;
2421
using Octokit.GraphQL.Model;
2522
using ReactiveUI;
2623
using Serilog;
2724
using PullRequestReviewEvent = Octokit.PullRequestReviewEvent;
2825
using static Octokit.GraphQL.Variable;
29-
using CheckAnnotationLevel = GitHub.Models.CheckAnnotationLevel;
30-
using CheckConclusionState = GitHub.Models.CheckConclusionState;
31-
using CheckStatusState = GitHub.Models.CheckStatusState;
3226
using DraftPullRequestReviewComment = Octokit.GraphQL.Model.DraftPullRequestReviewComment;
3327
using FileMode = System.IO.FileMode;
3428
using NotFoundException = LibGit2Sharp.NotFoundException;
35-
using PullRequestReviewState = Octokit.GraphQL.Model.PullRequestReviewState;
36-
using StatusState = GitHub.Models.StatusState;
3729

3830
// GraphQL DatabaseId field are marked as deprecated, but we need them for interop with REST.
3931
#pragma warning disable CS0618

0 commit comments

Comments
 (0)