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

Commit b6debc7

Browse files
committed
Display drafts for replies.
1 parent 8bddb0d commit b6debc7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/GitHub.App/ViewModels/PullRequestReviewCommentThreadViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel.Composition;
33
using System.Globalization;
44
using System.Linq;
5+
using System.Reactive.Linq;
56
using System.Threading.Tasks;
67
using GitHub.Extensions;
78
using 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

test/GitHub.App.UnitTests/ViewModels/CommentThreadViewModelTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Reactive.Concurrency;
3+
using System.Reactive.Linq;
34
using System.Threading.Tasks;
45
using GitHub.Models;
56
using 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)

0 commit comments

Comments
 (0)