This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +24
-19
lines changed
GitHub.Exports.Reactive/ViewModels/Documents
test/GitHub.App.UnitTests/ViewModels Expand file tree Collapse file tree 6 files changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ namespace GitHub.SampleData.Documents
1010 public class IssueishCommentThreadViewModelDesigner : ViewModelBase , IIssueishCommentThreadViewModel
1111 {
1212 public IActorViewModel CurrentUser { get ; } = new ActorViewModelDesigner ( "grokys" ) ;
13- public Task DeleteComment ( int pullRequestId , int commentId ) => Task . CompletedTask ;
14- public Task EditComment ( string id , string body ) => Task . CompletedTask ;
1513 public Task InitializeAsync ( ActorModel currentUser , IssueishDetailModel model , bool addPlaceholder ) => Task . CompletedTask ;
16- public Task PostComment ( string body ) => Task . CompletedTask ;
17- public Task CloseIssueish ( string body ) => Task . CompletedTask ;
14+ public Task DeleteComment ( ICommentViewModel comment ) => Task . CompletedTask ;
15+ public Task EditComment ( ICommentViewModel comment ) => Task . CompletedTask ;
16+ public Task PostComment ( ICommentViewModel comment ) => Task . CompletedTask ;
17+ public Task CloseIssueish ( ICommentViewModel comment ) => Task . CompletedTask ;
1818 }
1919}
Original file line number Diff line number Diff line change @@ -65,15 +65,13 @@ public CommentThreadViewModel(
6565 public abstract Task DeleteComment ( ICommentViewModel comment ) ;
6666
6767 /// <summary>
68- /// Adds a placeholder comment that will allow the user to enter a reply, and wires up
68+ /// Initializes a placeholder comment that will allow the user to enter a reply, and wires up
6969 /// event listeners for saving drafts.
7070 /// </summary>
7171 /// <param name="placeholder">The placeholder comment view model.</param>
7272 /// <returns>An object which when disposed will remove the event listeners.</returns>
73- protected IDisposable AddPlaceholder ( ICommentViewModel placeholder )
73+ protected IDisposable InitializePlaceholder ( ICommentViewModel placeholder )
7474 {
75- Comments . Add ( placeholder ) ;
76-
7775 return placeholder . WhenAnyValue (
7876 x => x . EditState ,
7977 x => x . Body ,
Original file line number Diff line number Diff line change @@ -108,25 +108,25 @@ await placeholder.InitializeAsync(
108108 }
109109
110110 /// <inheritdoc/>
111- public async Task PostComment ( string body )
111+ public async Task PostComment ( ICommentViewModel comment )
112112 {
113113 var address = HostAddress . Create ( Repository . CloneUrl ) ;
114- var comment = await service . PostComment ( address , Id , body ) . ConfigureAwait ( true ) ;
115- await AddComment ( comment ) . ConfigureAwait ( true ) ;
114+ var result = await service . PostComment ( address , Id , comment . Body ) . ConfigureAwait ( true ) ;
115+ await AddComment ( result ) . ConfigureAwait ( true ) ;
116116 ClearPlaceholder ( ) ;
117117 }
118118
119- Task ICommentThreadViewModel . DeleteComment ( int pullRequestId , int commentId )
119+ Task ICommentThreadViewModel . DeleteComment ( ICommentViewModel comment )
120120 {
121121 throw new NotImplementedException ( ) ;
122122 }
123123
124- Task ICommentThreadViewModel . EditComment ( string id , string body )
124+ Task ICommentThreadViewModel . EditComment ( ICommentViewModel comment )
125125 {
126126 throw new NotImplementedException ( ) ;
127127 }
128128
129- Task IIssueishCommentThreadViewModel . CloseIssueish ( string body )
129+ Task IIssueishCommentThreadViewModel . CloseIssueish ( ICommentViewModel comment )
130130 {
131131 throw new NotImplementedException ( ) ;
132132 }
Original file line number Diff line number Diff line change @@ -128,7 +128,8 @@ await vm.InitializeAsPlaceholderAsync(
128128 vm . Body = draft . Body ;
129129 }
130130
131- AddPlaceholder ( vm ) ;
131+ InitializePlaceholder ( vm ) ;
132+ comments . Add ( vm ) ;
132133 }
133134 }
134135
@@ -161,7 +162,8 @@ public async Task InitializeNewAsync(
161162 vm . Body = draft . Body ;
162163 }
163164
164- AddPlaceholder ( vm ) ;
165+ InitializePlaceholder ( vm ) ;
166+ comments . Add ( vm ) ;
165167 }
166168
167169 public override async Task PostComment ( ICommentViewModel comment )
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public interface IIssueishCommentThreadViewModel : ICommentThreadViewModel
1111 /// <summary>
1212 /// Called by a comment in the thread to close the issue or pull request.
1313 /// </summary>
14- /// <param name="body">The body of a comment to submit before closing .</param>
15- Task CloseIssueish ( string body ) ;
14+ /// <param name="body">The comment requesting the close .</param>
15+ Task CloseIssueish ( ICommentViewModel comment ) ;
1616 }
1717}
Original file line number Diff line number Diff line change 88using GitHub . ViewModels ;
99using NSubstitute ;
1010using NUnit . Framework ;
11+ using ReactiveUI ;
1112using ReactiveUI . Testing ;
1213
1314namespace GitHub . App . UnitTests . ViewModels
@@ -90,13 +91,17 @@ class Target : CommentThreadViewModel
9091 public Target ( IMessageDraftStore drafts , IScheduler scheduler )
9192 : base ( drafts , scheduler )
9293 {
94+ Comments = new ReactiveList < ICommentViewModel > ( ) ;
9395 }
9496
97+ public ReactiveList < ICommentViewModel > Comments { get ; }
98+
9599 public async Task AddPlaceholder ( bool isEditing )
96100 {
97101 var c = new TestComment ( ) ;
98102 await c . InitializeAsPlaceholderAsync ( this , isEditing ) ;
99- AddPlaceholder ( c ) ;
103+ InitializePlaceholder ( c ) ;
104+ Comments . Add ( c ) ;
100105 }
101106
102107 public override Task DeleteComment ( ICommentViewModel comment ) => Task . CompletedTask ;
You can’t perform that action at this time.
0 commit comments