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

Commit 58e260d

Browse files
committed
Fix start page clone.
- When no connection is passed into `DialogService.ShowCloneDialog`, call `ShowWithFirstConnection` to ensure a connection exists. - Fix bug in `ShowWithFirstConnection` where the task it returns can't be completed until the UI is shown! - Fixed exception that was appearing in log: `GetServiceSafe: Could not obtain instance of 'Microsoft.TeamFoundation.Controls.ITeamExplorerPage'` Fixes #1927
1 parent ff10830 commit 58e260d

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/GitHub.App/Services/DialogService.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@ public DialogService(
3131

3232
public async Task<CloneDialogResult> ShowCloneDialog(IConnection connection)
3333
{
34-
Guard.ArgumentNotNull(connection, nameof(connection));
35-
3634
var viewModel = factory.CreateViewModel<IRepositoryCloneViewModel>();
3735

38-
return (CloneDialogResult)await showDialog.Show(
39-
viewModel,
40-
connection,
41-
ApiClientConfiguration.RequestedScopes)
42-
.ConfigureAwait(false);
36+
if (connection != null)
37+
{
38+
return (CloneDialogResult)await showDialog.Show(
39+
viewModel,
40+
connection,
41+
ApiClientConfiguration.RequestedScopes)
42+
.ConfigureAwait(false);
43+
}
44+
else
45+
{
46+
return (CloneDialogResult)await showDialog.ShowWithFirstConnection(viewModel)
47+
.ConfigureAwait(false);
48+
}
4349
}
4450

4551
public async Task<string> ShowReCloneDialog(IRepositoryModel repository)

src/GitHub.TeamFoundation.14/Base/TeamExplorerSectionBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public virtual void SaveContext(object sender, SectionSaveContextEventArgs e)
118118

119119
protected ITeamExplorerSection GetSection(Guid section)
120120
{
121-
var tep = (ITeamExplorerPage)TEServiceProvider.GetServiceSafe(typeof(ITeamExplorerPage));
121+
// Return null if section hasn't been initialized yet
122+
var tep = (ITeamExplorerPage)TEServiceProvider?.GetServiceSafe(typeof(ITeamExplorerPage));
122123
return tep?.GetSection(section);
123124
}
124125
}

src/GitHub.VisualStudio/Services/ShowDialogService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public async Task<object> ShowWithFirstConnection<TViewModel>(TViewModel viewMod
7575
using (var dialogViewModel = CreateViewModel())
7676
using (dialogViewModel.Done.Take(1).Subscribe(x => result = x))
7777
{
78-
await dialogViewModel.StartWithConnection(viewModel);
79-
78+
var task = dialogViewModel.StartWithConnection(viewModel);
8079
var window = new GitHubDialogWindow(dialogViewModel);
8180
window.ShowModal();
81+
await task;
8282
}
8383

8484
return result;

0 commit comments

Comments
 (0)