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

Commit 0d9e7fc

Browse files
committed
Activate connection after logging in
1 parent 8bdccb2 commit 0d9e7fc

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/GitHub.App/ViewModels/Dialog/Clone/RepositoryCloneViewModel.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
3333
RepositoryModel previousRepository;
3434
ObservableAsPropertyHelper<string> pathWarning;
3535
int selectedTabIndex;
36+
IDisposable selectedTabIndexSubscription;
3637

3738
[ImportingConstructor]
3839
public RepositoryCloneViewModel(
@@ -86,13 +87,7 @@ public RepositoryCloneViewModel(
8687
() => repository.Select(x => new CloneDialogResult(Path, x?.CloneUrl)),
8788
canOpen);
8889

89-
LoginAsDifferentUser = ReactiveCommand.CreateFromTask(async () =>
90-
{
91-
if (await dialogService.ShowLoginDialog() is IConnection connection)
92-
{
93-
await InitializeAsync(connection);
94-
}
95-
});
90+
LoginAsDifferentUser = ReactiveCommand.CreateFromTask(LoginAsDifferentUserAsync);
9691
}
9792

9893
public IRepositorySelectViewModel GitHubTab { get; }
@@ -172,6 +167,28 @@ public async Task InitializeAsync(IConnection connection)
172167
this.WhenAnyValue(x => x.SelectedTabIndex).Subscribe(x => tabs[x].Activate().Forget());
173168
}
174169

170+
async Task LoginAsDifferentUserAsync()
171+
{
172+
if (await dialogService.ShowLoginDialog() is IConnection connection)
173+
{
174+
var connections = await connectionManager.GetLoadedConnections();
175+
var gitHubConnection = connections.FirstOrDefault(x => x.HostAddress.IsGitHubDotCom());
176+
177+
if (connection == gitHubConnection)
178+
{
179+
SelectedTabIndex = 0;
180+
GitHubTab.Initialize(connection);
181+
GitHubTab.Activate().Forget();
182+
}
183+
else
184+
{
185+
SelectedTabIndex = 1;
186+
EnterpriseTab.Initialize(connection);
187+
EnterpriseTab.Activate().Forget();
188+
}
189+
}
190+
}
191+
175192
void BrowseForDirectory()
176193
{
177194
var result = os.Dialog.BrowseForDirectory(Path, Resources.BrowseForDirectory);

0 commit comments

Comments
 (0)