@@ -434,23 +434,12 @@ public async Task<PullRequestDetailModel> CreatePendingReview(
434434 {
435435 var address = HostAddress . Create ( localRepository . CloneUrl . Host ) ;
436436 var graphql = await graphqlFactory . CreateConnection ( address ) ;
437+ var ( _, owner , number ) = await CreatePendingReviewCore ( localRepository , pullRequestId ) ;
438+ var detail = await ReadPullRequestDetail ( address , owner , localRepository . Name , number ) ;
437439
438- var review = new AddPullRequestReviewInput
439- {
440- PullRequestId = new ID ( pullRequestId ) ,
441- } ;
442-
443- var mutation = new Mutation ( )
444- . AddPullRequestReview ( review )
445- . Select ( x => new
446- {
447- x . PullRequestReview . Repository . Owner . Login ,
448- x . PullRequestReview . PullRequest . Number
449- } ) ;
450-
451- var result = await graphql . Run ( mutation ) ;
452440 await usageTracker . IncrementCounter ( x => x . NumberOfPRReviewDiffViewInlineCommentStartReview ) ;
453- return await ReadPullRequestDetail ( address , result . Login , localRepository . Name , result . Number ) ;
441+
442+ return detail ;
454443 }
455444
456445 /// <inheritdoc/>
@@ -652,9 +641,9 @@ public async Task<PullRequestDetailModel> PostStandaloneReviewCommentReply(
652641 string body ,
653642 string inReplyTo )
654643 {
655- var review = await CreatePendingReview ( localRepository , pullRequestId ) ;
656- var comment = await PostPendingReviewCommentReply ( localRepository , review . Id , body , inReplyTo ) ;
657- return await SubmitPendingReview ( localRepository , review . Id , null , PullRequestReviewEvent . Comment ) ;
644+ var ( id , _ , _ ) = await CreatePendingReviewCore ( localRepository , pullRequestId ) ;
645+ var comment = await PostPendingReviewCommentReply ( localRepository , id , body , inReplyTo ) ;
646+ return await SubmitPendingReview ( localRepository , id , null , PullRequestReviewEvent . Comment ) ;
658647 }
659648
660649 /// <inheritdoc/>
@@ -702,6 +691,29 @@ public async Task<PullRequestDetailModel> EditComment(ILocalRepositoryModel loca
702691 return await ReadPullRequestDetail ( address , result . Login , localRepository . Name , result . Number ) ;
703692 }
704693
694+ async Task < ( string id , string owner , int number ) > CreatePendingReviewCore ( ILocalRepositoryModel localRepository , string pullRequestId )
695+ {
696+ var address = HostAddress . Create ( localRepository . CloneUrl . Host ) ;
697+ var graphql = await graphqlFactory . CreateConnection ( address ) ;
698+
699+ var input = new AddPullRequestReviewInput
700+ {
701+ PullRequestId = new ID ( pullRequestId ) ,
702+ } ;
703+
704+ var mutation = new Mutation ( )
705+ . AddPullRequestReview ( input )
706+ . Select ( x => new
707+ {
708+ Id = x . PullRequestReview . Id . Value ,
709+ Owner = x . PullRequestReview . Repository . Owner . Login ,
710+ x . PullRequestReview . PullRequest . Number
711+ } ) ;
712+
713+ var result = await graphql . Run ( mutation ) ;
714+ return ( result . Id , result . Owner , result . Number ) ;
715+ }
716+
705717 int GetUpdatedLineNumber ( IInlineCommentThreadModel thread , IEnumerable < DiffChunk > diff )
706718 {
707719 var line = DiffUtilities . Match ( diff , thread . DiffMatch ) ;
@@ -724,7 +736,7 @@ Task<IRepository> GetRepository(ILocalRepositoryModel repository)
724736 static void BuildPullRequestThreads ( PullRequestDetailModel model )
725737 {
726738 var commentsByReplyId = new Dictionary < string , List < CommentAdapter > > ( ) ;
727-
739+
728740 // Get all comments that are not replies.
729741 foreach ( CommentAdapter comment in model . Reviews . SelectMany ( x => x . Comments ) )
730742 {
0 commit comments