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

Commit 1308c0e

Browse files
committed
Implemented edit/delete of comments.
1 parent c3f9778 commit 1308c0e

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

src/GitHub.App/Services/IssueishService.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,26 @@ public async Task<CommentModel> PostComment(HostAddress address, string issueish
8888
var graphql = await graphqlFactory.CreateConnection(address).ConfigureAwait(false);
8989
return await graphql.Run(postComment, vars).ConfigureAwait(false);
9090
}
91+
92+
public async Task DeleteComment(
93+
HostAddress address,
94+
string owner,
95+
string repository,
96+
int commentId)
97+
{
98+
var client = await apiClientFactory.CreateGitHubClient(address).ConfigureAwait(false);
99+
await client.Issue.Comment.Delete(owner, repository, commentId).ConfigureAwait(false);
100+
}
101+
102+
public async Task EditComment(
103+
HostAddress address,
104+
string owner,
105+
string repository,
106+
int commentId,
107+
string body)
108+
{
109+
var client = await apiClientFactory.CreateGitHubClient(address).ConfigureAwait(false);
110+
await client.Issue.Comment.Update(owner, repository, commentId, body).ConfigureAwait(false);
111+
}
91112
}
92113
}

src/GitHub.App/ViewModels/Documents/PullRequestPageViewModel.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,24 @@ public async Task PostComment(ICommentViewModel comment)
143143
await AddPlaceholder().ConfigureAwait(true);
144144
}
145145

146-
Task ICommentThreadViewModel.DeleteComment(ICommentViewModel comment)
146+
public async Task DeleteComment(ICommentViewModel comment)
147147
{
148-
throw new NotImplementedException();
148+
await service.DeleteComment(
149+
HostAddress.Create(Repository.CloneUrl),
150+
Repository.Owner,
151+
Repository.Name,
152+
comment.DatabaseId).ConfigureAwait(true);
153+
timeline.Remove(comment);
149154
}
150155

151-
Task ICommentThreadViewModel.EditComment(ICommentViewModel comment)
156+
public async Task EditComment(ICommentViewModel comment)
152157
{
153-
throw new NotImplementedException();
158+
await service.EditComment(
159+
HostAddress.Create(Repository.CloneUrl),
160+
Repository.Owner,
161+
Repository.Name,
162+
comment.DatabaseId,
163+
comment.Body).ConfigureAwait(false);
154164
}
155165

156166
async Task AddComment(CommentModel comment)

src/GitHub.Exports.Reactive/Services/IIssueishService.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,33 @@ Task<CommentModel> PostComment(
3939
HostAddress address,
4040
string issueishId,
4141
string body);
42+
43+
/// <summary>
44+
/// Deletes an issue or pull request comment.
45+
/// </summary>
46+
/// <param name="address">The address of the server.</param>
47+
/// <param name="owner">The repository owner.</param>
48+
/// <param name="repository">The repository name.</param>
49+
/// <param name="commentId">The database ID of the comment.</param>
50+
Task DeleteComment(
51+
HostAddress address,
52+
string owner,
53+
string repository,
54+
int commentId);
55+
56+
/// <summary>
57+
/// Edits an issue or pull request comment.
58+
/// </summary>
59+
/// <param name="address">The address of the server.</param>
60+
/// <param name="owner">The repository owner.</param>
61+
/// <param name="repository">The repository name.</param>
62+
/// <param name="commentId">The database ID of the comment.</param>
63+
/// <param name="body">The new comment body.</param>
64+
Task EditComment(
65+
HostAddress address,
66+
string owner,
67+
string repository,
68+
int commentId,
69+
string body);
4270
}
4371
}

0 commit comments

Comments
 (0)