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

Commit bf27bc6

Browse files
authored
Merge pull request #1034 from github/fixes/cancel-closes-new-comment
Close peek session when Cancel clicked on new inline comment thead.
2 parents 1f926c6 + 016f4a0 commit bf27bc6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/GitHub.InlineReviews/Peek/InlineCommentPeekableItem.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ namespace GitHub.InlineReviews.Peek
77
{
88
class InlineCommentPeekableItem : IPeekableItem
99
{
10-
readonly InlineCommentPeekViewModel viewModel;
11-
1210
public InlineCommentPeekableItem(InlineCommentPeekViewModel viewModel)
1311
{
14-
this.viewModel = viewModel;
12+
ViewModel = viewModel;
1513
}
1614

1715
public string DisplayName => "GitHub Code Review";
16+
public InlineCommentPeekViewModel ViewModel { get; }
1817

1918
public IEnumerable<IPeekRelationship> Relationships => new[] { InlineCommentPeekRelationship.Instance };
2019

2120
public IPeekResultSource GetOrCreateResultSource(string relationshipName)
2221
{
23-
return new InlineCommentPeekableResultSource(viewModel);
22+
return new InlineCommentPeekableResultSource(ViewModel);
2423
}
2524
}
2625
}

src/GitHub.InlineReviews/Services/InlineCommentPeekService.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.ComponentModel.Composition;
3+
using System.Linq;
4+
using System.Reactive.Linq;
35
using System.Threading.Tasks;
46
using GitHub.Api;
57
using GitHub.Extensions;
@@ -96,7 +98,15 @@ public ITrackingPoint Show(ITextView textView, AddInlineCommentTag tag)
9698

9799
ExpandCollapsedRegions(textView, line.Extent);
98100

99-
peekBroker.TriggerPeekSession(textView, trackingPoint, InlineCommentPeekRelationship.Instance.Name);
101+
var session = peekBroker.TriggerPeekSession(textView, trackingPoint, InlineCommentPeekRelationship.Instance.Name);
102+
var item = session.PeekableItems.OfType<InlineCommentPeekableItem>().FirstOrDefault();
103+
104+
if (item != null)
105+
{
106+
var placeholder = item.ViewModel.Thread.Comments.Last();
107+
placeholder.CancelEdit.Take(1).Subscribe(_ => session.Dismiss());
108+
}
109+
100110
return trackingPoint;
101111
}
102112

0 commit comments

Comments
 (0)