@@ -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