Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public PullRequestListViewModelDesigner()

public IReadOnlyList<IRemoteRepositoryModel> Repositories { get; }
public IRemoteRepositoryModel SelectedRepository { get; set; }

public IPullRequestModel CheckedOutPullRequest { get; set; }
public ITrackingCollection<IPullRequestModel> PullRequests { get; set; }
public IPullRequestModel SelectedPullRequest { get; set; }

Expand Down
22 changes: 22 additions & 0 deletions src/GitHub.App/ViewModels/GitHubPane/PullRequestListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
public PullRequestListViewModel(
IModelServiceFactory modelServiceFactory,
IPackageSettings settings,
IPullRequestSessionManager sessionManager,
IVisualStudioBrowser visualStudioBrowser)
{
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
Guard.ArgumentNotNull(settings, nameof(settings));
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));

constructing = true;
Expand Down Expand Up @@ -100,6 +102,19 @@ public PullRequestListViewModel(
OpenPullRequestOnGitHub = ReactiveCommand.Create();
OpenPullRequestOnGitHub.Subscribe(x => DoOpenPullRequestOnGitHub((int)x));

// Get the current pull request session and the selected repository. When the session's
// repository is the same as our selected repository set CheckedOutPullRequest to the
// current session's model, so that the checked out PR can be highlighted.
Observable.CombineLatest(
sessionManager.WhenAnyValue(x => x.CurrentSession),
this.WhenAnyValue(x => x.SelectedRepository),
(s, r) => new { Session = s, Repository = r })
.Subscribe(x =>
{
CheckedOutPullRequest = x.Session?.RepositoryOwner == x.Repository?.Owner ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you only checking the repository owner here?

x.Session?.PullRequest : null;
});

constructing = false;
}

Expand Down Expand Up @@ -245,6 +260,13 @@ public IPullRequestModel SelectedPullRequest
set { this.RaiseAndSetIfChanged(ref selectedPullRequest, value); }
}

IPullRequestModel checkedOutPullRequest;
public IPullRequestModel CheckedOutPullRequest
{
get { return checkedOutPullRequest; }
set { this.RaiseAndSetIfChanged(ref checkedOutPullRequest, value); }
}

IReadOnlyList<PullRequestState> states;
public IReadOnlyList<PullRequestState> States
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public interface IPullRequestListViewModel : ISearchablePageViewModel, IOpenInBr
IRemoteRepositoryModel SelectedRepository { get; set; }
ITrackingCollection<IPullRequestModel> PullRequests { get; }
IPullRequestModel SelectedPullRequest { get; }
IPullRequestModel CheckedOutPullRequest { get; }
IReadOnlyList<PullRequestState> States { get; set; }
PullRequestState SelectedState { get; set; }
ObservableCollection<IAccount> Authors { get; }
Expand Down
33 changes: 33 additions & 0 deletions src/GitHub.UI/Converters/EqualityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Windows;

namespace GitHub.UI
{
[Localizability(LocalizationCategory.NeverLocalize)]
public sealed class EqualityConverter : MultiValueConverterMarkupExtension<EqualityConverter>
{
public override object Convert(
object[] value,
Type targetType,
object parameter,
CultureInfo culture)
{
if (value.Length == 2)
{
return Equals(value[0], value[1]);
}

return false;
}

public override object[] ConvertBack(
object value,
Type[] targetType,
object parameter,
CultureInfo culture)
{
return null;
}
}
}
1 change: 1 addition & 0 deletions src/GitHub.UI/GitHub.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<DependentUpon>Spinner.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\AllCapsConverter.cs" />
<Compile Include="Converters\EqualityConverter.cs" />
<Compile Include="Converters\EqualsToVisibilityConverter.cs" />
<Compile Include="Converters\MultiBooleanToVisibilityConverter.cs" />
<Compile Include="Converters\NullToVisibilityConverter.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/GitHub.VisualStudio.UI/Styles/ThemeBlue.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@
<SolidColorBrush x:Key="GitHubDiffGlyphFill.None" Color="#9EC7FF" />

<SolidColorBrush x:Key="GitHubPeekViewBackground" Color="#F5F5F5" />
<SolidColorBrush x:Key="GitHubMultilineListItemActiveBrush" Color="#FFCCCEDB"/>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/GitHub.VisualStudio.UI/Styles/ThemeDark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@
<SolidColorBrush x:Key="GitHubDiffGlyphFill.None" Color="#569CD6" />

<SolidColorBrush x:Key="GitHubPeekViewBackground" Color="#252526" />
<SolidColorBrush x:Key="GitHubMultilineListItemActiveBrush" Color="#FF3F3F46"/>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/GitHub.VisualStudio.UI/Styles/ThemeLight.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@
<SolidColorBrush x:Key="GitHubDiffGlyphFill.None" Color="#9EC7FF" />

<SolidColorBrush x:Key="GitHubPeekViewBackground" Color="#F5F5F5" />
<SolidColorBrush x:Key="GitHubMultilineListItemActiveBrush" Color="#FFCCCEDB"/>
</ResourceDictionary>
Loading