This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 191191 <Project >{9aea02db-02b5-409c-b0ca-115d05331a6b}</Project >
192192 <Name >GitHub.Exports</Name >
193193 </ProjectReference >
194+ <ProjectReference Include =" ..\GitHub.Extensions.Reactive\GitHub.Extensions.Reactive.csproj" >
195+ <Project >{6559E128-8B40-49A5-85A8-05565ED0C7E3}</Project >
196+ <Name >GitHub.Extensions.Reactive</Name >
197+ </ProjectReference >
194198 <ProjectReference Include =" ..\GitHub.Extensions\GitHub.Extensions.csproj" >
195199 <Project >{6AFE2E2D-6DB0-4430-A2EA-F5F5388D2F78}</Project >
196200 <Name >GitHub.Extensions</Name >
Original file line number Diff line number Diff line change @@ -107,12 +107,7 @@ public ITrackingPoint Show(ITextView textView, AddInlineCommentTag tag)
107107
108108 var session = peekBroker . TriggerPeekSession ( options ) ;
109109 var item = session . PeekableItems . OfType < InlineCommentPeekableItem > ( ) . FirstOrDefault ( ) ;
110-
111- if ( item != null )
112- {
113- var placeholder = item . ViewModel . Thread . Comments . Last ( ) ;
114- placeholder . CancelEdit . Take ( 1 ) . Subscribe ( _ => session . Dismiss ( ) ) ;
115- }
110+ item ? . ViewModel . Close . Take ( 1 ) . Subscribe ( _ => session . Dismiss ( ) ) ;
116111
117112 return trackingPoint ;
118113 }
@@ -134,7 +129,9 @@ public ITrackingPoint Show(ITextView textView, ShowInlineCommentTag tag)
134129
135130 ExpandCollapsedRegions ( textView , line . Extent ) ;
136131
137- peekBroker . TriggerPeekSession ( options ) ;
132+ var session = peekBroker . TriggerPeekSession ( options ) ;
133+ var item = session . PeekableItems . OfType < InlineCommentPeekableItem > ( ) . FirstOrDefault ( ) ;
134+ item ? . ViewModel . Close . Take ( 1 ) . Subscribe ( _ => session . Dismiss ( ) ) ;
138135
139136 return trackingPoint ;
140137 }
Original file line number Diff line number Diff line change 77using GitHub . Api ;
88using GitHub . Commands ;
99using GitHub . Extensions ;
10+ using GitHub . Extensions . Reactive ;
1011using GitHub . Factories ;
1112using GitHub . InlineReviews . Commands ;
1213using GitHub . InlineReviews . Services ;
@@ -63,6 +64,11 @@ public InlineCommentPeekViewModel(
6364
6465 peekSession . Dismissed += ( s , e ) => Dispose ( ) ;
6566
67+ Close = this . WhenAnyValue ( x => x . Thread )
68+ . SelectMany ( x => x is NewInlineCommentThreadViewModel
69+ ? x . Comments . Single ( ) . CancelEdit . SelectUnit ( )
70+ : Observable . Never < Unit > ( ) ) ;
71+
6672 NextComment = ReactiveCommand . CreateAsyncTask (
6773 Observable . Return ( nextCommentCommand . Enabled ) ,
6874 _ => nextCommentCommand . Execute ( new InlineCommentNavigationParams
@@ -97,6 +103,8 @@ public ICommentThreadViewModel Thread
97103 /// </summary>
98104 public ReactiveCommand < Unit > PreviousComment { get ; }
99105
106+ public IObservable < Unit > Close { get ; }
107+
100108 public void Dispose ( )
101109 {
102110 threadSubscription ? . Dispose ( ) ;
You can’t perform that action at this time.
0 commit comments