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

Commit f976412

Browse files
committed
Display PR title as pane caption.
1 parent 424439d commit f976412

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class IssueishPaneViewModel : ViewModelBase, IIssueishPaneViewModel
1616
readonly IViewViewModelFactory factory;
1717
readonly IPullRequestSessionManager sessionManager;
1818
IViewModel content;
19+
string paneCaption;
1920

2021
[ImportingConstructor]
2122
public IssueishPaneViewModel(
@@ -35,6 +36,12 @@ public IViewModel Content
3536
private set => this.RaiseAndSetIfChanged(ref content, value);
3637
}
3738

39+
public string PaneCaption
40+
{
41+
get => paneCaption;
42+
private set => this.RaiseAndSetIfChanged(ref paneCaption, value);
43+
}
44+
3845
public Task InitializeAsync(IServiceProvider paneServiceProvider)
3946
{
4047
return Task.CompletedTask;
@@ -43,6 +50,7 @@ public Task InitializeAsync(IServiceProvider paneServiceProvider)
4350
public async Task Load(IConnection connection, string owner, string name, int number)
4451
{
4552
Content = new SpinnerViewModel();
53+
PaneCaption = "#" + number;
4654

4755
// TODO: We will eventually support loading issues here as well.
4856
try
@@ -65,6 +73,7 @@ await vm.InitializeAsync(
6573
session.User,
6674
session.PullRequest).ConfigureAwait(true);
6775
Content = vm;
76+
PaneCaption += " " + vm.Title;
6877
}
6978
catch (Exception ex)
7079
{

src/GitHub.Exports/ViewModels/IPaneViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace GitHub.ViewModels
88
/// </summary>
99
public interface IPaneViewModel : IViewModel
1010
{
11+
/// <summary>
12+
/// Gets the caption for the tool window.
13+
/// </summary>
14+
string PaneCaption { get; }
15+
1116
/// <summary>
1217
/// Initializes the view model.
1318
/// </summary>

src/GitHub.VisualStudio/UI/AsyncPaneBase.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
using GitHub.ViewModels;
99
using Microsoft.VisualStudio.Shell;
1010
using Microsoft.VisualStudio.Threading;
11+
using ReactiveUI;
1112

1213
namespace GitHub.VisualStudio.UI
1314
{
1415
public class AsyncPaneBase<TViewModel> : ToolWindowPane
1516
where TViewModel : IPaneViewModel
1617
{
1718
readonly ContentPresenter contentPresenter;
19+
IDisposable subscription;
1820
JoinableTask<TViewModel> viewModelTask;
1921

2022
public AsyncPaneBase()
@@ -38,6 +40,17 @@ protected override void Initialize()
3840

3941
public Task<TViewModel> GetViewModelAsync() => viewModelTask.JoinAsync();
4042

43+
protected override void Dispose(bool disposing)
44+
{
45+
base.Dispose(disposing);
46+
47+
if (disposing)
48+
{
49+
subscription?.Dispose();
50+
subscription = null;
51+
}
52+
}
53+
4154
async Task<TViewModel> InitializeAsync(AsyncPackage asyncPackage)
4255
{
4356
try
@@ -55,6 +68,7 @@ async Task<TViewModel> InitializeAsync(AsyncPackage asyncPackage)
5568
throw new CompositionException("Could not find view for " + typeof(TViewModel).FullName);
5669
}
5770
View.DataContext = viewModel;
71+
subscription = viewModel.WhenAnyValue(x => x.PaneCaption).Subscribe(x => Caption = x);
5872
return viewModel;
5973
}
6074
catch (Exception e)

0 commit comments

Comments
 (0)