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

Commit aeb4469

Browse files
committed
Rewrite logic of loading individual views in the GitHubPane
Rewrite the logic of loading individual views that are not controlled by an UIController in the GitHubPane, so it's clearer what needs to happen and in which conditions.
1 parent ffc51af commit aeb4469

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,34 +118,37 @@ async Task Reload([AllowNull] ViewWithData data = null, bool navigating = false)
118118

119119
if (!IsGitHubRepo.Value)
120120
{
121-
Stop();
121+
//LoadView(UIViewType.NotAGitHubRepo);
122122
return;
123123
}
124124

125125
var connection = await connectionManager.LookupConnection(ActiveRepo);
126126
IsLoggedIn = await connection.IsLoggedIn(hosts);
127127

128-
if (IsLoggedIn)
128+
if (!IsLoggedIn)
129129
{
130-
if (uiController == null || (data != null && data.ActiveFlow != uiController.CurrentFlow))
131-
StartFlow(data?.ActiveFlow ?? UIControllerFlow.PullRequests, connection, data);
132-
else if (data != null || currentNavItem >= 0)
133-
uiController.Jump(data ?? navStack[currentNavItem]);
134-
}
135-
else
136-
{
137-
var factory = ServiceProvider.GetExportedValue<IUIFactory>();
138-
var c = factory.CreateViewAndViewModel(UIViewType.LoggedOut);
139-
c.View.DataContext = c.ViewModel;
140-
Control = c.View;
130+
LoadView(UIViewType.LoggedOut);
131+
return;
141132
}
142-
return;
133+
134+
if (uiController == null || (data != null && data.ActiveFlow != uiController.SelectedFlow))
135+
StartFlow(data?.ActiveFlow ?? UIControllerFlow.PullRequests, connection, data);
136+
else if (data != null || currentNavItem >= 0)
137+
uiController.Jump(data ?? navStack[currentNavItem]);
138+
}
139+
140+
void LoadView(UIViewType type)
141+
{
142+
Stop();
143+
var factory = ServiceProvider.GetExportedValue<IUIFactory>();
144+
var c = factory.CreateViewAndViewModel(type);
145+
c.View.DataContext = c.ViewModel;
146+
Control = c.View;
143147
}
144148

145149
void StartFlow(UIControllerFlow controllerFlow, [AllowNull]IConnection conn, ViewWithData data = null)
146150
{
147-
if (uiController != null)
148-
Stop();
151+
Stop();
149152

150153
if (conn == null)
151154
return;

0 commit comments

Comments
 (0)