This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
src/GitHub.App/ViewModels
test/GitHub.App.UnitTests/ViewModels Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 22using System . ComponentModel . Composition ;
33using System . Globalization ;
44using System . Linq ;
5+ using System . Reactive . Linq ;
56using System . Threading . Tasks ;
67using GitHub . Extensions ;
78using GitHub . Factories ;
@@ -107,6 +108,15 @@ await vm.InitializeAsync(
107108 var vm = factory . CreateViewModel < IPullRequestReviewCommentViewModel > ( ) ;
108109 await vm . InitializeAsPlaceholderAsync ( session , this , false ) . ConfigureAwait ( true ) ;
109110 Comments . Add ( vm ) ;
111+
112+ var ( key , secondaryKey ) = GetDraftKeys ( vm ) ;
113+ var draft = await DraftStore . GetDraft < PullRequestReviewCommentDraft > ( key , secondaryKey ) . ConfigureAwait ( true ) ;
114+
115+ if ( draft ? . Side == Side )
116+ {
117+ await vm . BeginEdit . Execute ( ) ;
118+ vm . Body = draft . Body ;
119+ }
110120 }
111121 }
112122
Original file line number Diff line number Diff line change 11using System ;
22using System . Reactive . Concurrency ;
3+ using System . Reactive . Linq ;
34using System . Threading . Tasks ;
45using GitHub . Models ;
56using GitHub . Models . Drafts ;
@@ -54,6 +55,21 @@ public async Task DoesntSaveDraftForNonEditingComment()
5455 }
5556 }
5657
58+ [ Test ]
59+ public async Task CancelEditDeletesDraft ( )
60+ {
61+ using ( TestUtils . WithScheduler ( Scheduler . CurrentThread ) )
62+ {
63+ var drafts = Substitute . For < IMessageDraftStore > ( ) ;
64+ var target = CreateTarget ( drafts : drafts ) ;
65+
66+ await target . AddPlaceholder ( false ) ;
67+ await target . Comments [ 0 ] . CancelEdit . Execute ( ) ;
68+
69+ await drafts . Received ( ) . DeleteDraft ( "file.cs" , "10" ) ;
70+ }
71+ }
72+
5773 static Target CreateTarget (
5874 IMessageDraftStore drafts = null ,
5975 IScheduler scheduler = null )
You can’t perform that action at this time.
0 commit comments