@@ -98,22 +98,17 @@ public async Task InitializeAsync(
9898 timeline . Add ( new CommitSummariesViewModel ( commits ) ) ;
9999 }
100100
101- var placeholder = factory . CreateViewModel < IIssueishCommentViewModel > ( ) ;
102- await placeholder . InitializeAsync (
103- this ,
104- currentUser ,
105- null ,
106- Resources . ClosePullRequest ) . ConfigureAwait ( true ) ;
107- timeline . Add ( placeholder ) ;
101+ await AddPlaceholder ( ) . ConfigureAwait ( true ) ;
108102 }
109103
110104 /// <inheritdoc/>
111105 public async Task PostComment ( ICommentViewModel comment )
112106 {
113107 var address = HostAddress . Create ( Repository . CloneUrl ) ;
114108 var result = await service . PostComment ( address , Id , comment . Body ) . ConfigureAwait ( true ) ;
109+ timeline . Remove ( comment ) ;
115110 await AddComment ( result ) . ConfigureAwait ( true ) ;
116- ClearPlaceholder ( ) ;
111+ await AddPlaceholder ( ) . ConfigureAwait ( true ) ;
117112 }
118113
119114 Task ICommentThreadViewModel . DeleteComment ( ICommentViewModel comment )
@@ -135,37 +130,18 @@ async Task AddComment(CommentModel comment)
135130 {
136131 var vm = factory . CreateViewModel < IIssueishCommentViewModel > ( ) ;
137132 await vm . InitializeAsync ( this , currentUserModel , comment , null ) . ConfigureAwait ( true ) ;
138-
139- if ( GetPlaceholder ( ) == null )
140- {
141- timeline . Add ( vm ) ;
142- }
143- else
144- {
145- timeline . Insert ( timeline . Count - 1 , vm ) ;
146- }
147- }
148-
149- void ClearPlaceholder ( )
150- {
151- var placeholder = GetPlaceholder ( ) ;
152-
153- if ( placeholder != null )
154- {
155- placeholder . Body = null ;
156- }
133+ timeline . Add ( vm ) ;
157134 }
158135
159- ICommentViewModel GetPlaceholder ( )
136+ async Task AddPlaceholder ( )
160137 {
161- if ( timeline . Count > 0 &&
162- timeline [ timeline . Count - 1 ] is ICommentViewModel comment &&
163- comment . Id == null )
164- {
165- return comment ;
166- }
167-
168- return null ;
138+ var placeholder = factory . CreateViewModel < IIssueishCommentViewModel > ( ) ;
139+ await placeholder . InitializeAsync (
140+ this ,
141+ currentUserModel ,
142+ null ,
143+ Resources . ClosePullRequest ) . ConfigureAwait ( true ) ;
144+ timeline . Add ( placeholder ) ;
169145 }
170146
171147 async Task DoShowCommit ( string oid )
0 commit comments