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

Commit 18cd657

Browse files
author
Steven Kirk
committed
Fix failing test.
Added a `PullRequestChanged` signal to `IPullRequestSession` because the pull request model may be changed in-place and rxui filters out non-distinct entries in a `WhenAny`.
1 parent 1489285 commit 18cd657

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ public interface IPullRequestSession
2525
/// </summary>
2626
IPullRequestModel PullRequest { get; }
2727

28+
/// <summary>
29+
/// Gets an observable that indicates that<see cref="PullRequest"/> has been updated.
30+
/// </summary>
31+
/// <remarks>
32+
/// This notification is different to listening for a PropertyChanged event because the
33+
/// pull request model may be updated in-place which will not result in a PropertyChanged
34+
/// notification.
35+
/// </remarks>
36+
IObservable<IPullRequestModel> PullRequestChanged { get; }
37+
2838
/// <summary>
2939
/// Gets the local repository.
3040
/// </summary>

src/GitHub.InlineReviews/Services/PullRequestSession.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using GitHub.Services;
1010
using ReactiveUI;
1111
using System.Threading;
12+
using System.Reactive.Subjects;
1213

1314
namespace GitHub.InlineReviews.Services
1415
{
@@ -30,6 +31,7 @@ public class PullRequestSession : ReactiveObject, IPullRequestSession
3031
string mergeBase;
3132
IReadOnlyList<IPullRequestSessionFile> files;
3233
IPullRequestModel pullRequest;
34+
Subject<IPullRequestModel> pullRequestChanged = new Subject<IPullRequestModel>();
3335

3436
public PullRequestSession(
3537
IPullRequestSessionService service,
@@ -155,6 +157,8 @@ public async Task Update(IPullRequestModel pullRequest)
155157
{
156158
await UpdateFile(file);
157159
}
160+
161+
pullRequestChanged.OnNext(pullRequest);
158162
}
159163

160164
async Task AddComment(IPullRequestReviewCommentModel comment)
@@ -233,6 +237,9 @@ private set
233237
}
234238
}
235239

240+
/// <inheritdoc/>
241+
public IObservable<IPullRequestModel> PullRequestChanged => pullRequestChanged;
242+
236243
/// <inheritdoc/>
237244
public ILocalRepositoryModel LocalRepository { get; }
238245

src/GitHub.InlineReviews/Services/PullRequestSessionManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ public async Task<IPullRequestSessionFile> GetLiveFile(
109109
dispose.Add(this.WhenAnyValue(x => x.CurrentSession)
110110
.Skip(1)
111111
.Subscribe(_ => UpdateLiveFile(result, true).Forget()));
112-
dispose.Add(this.WhenAnyValue(x => x.CurrentSession.PullRequest)
113-
.Skip(1)
112+
dispose.Add(this.WhenAnyObservable(x => x.CurrentSession.PullRequestChanged)
114113
.Subscribe(_ => UpdateLiveFile(result, true).Forget()));
115114

116115
result.ToDispose = dispose;

0 commit comments

Comments
 (0)