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

Commit 304485e

Browse files
committed
Fixed spinner showing when logged out.
1 parent f8e48fb commit 304485e

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/GitHub.App/ViewModels/GitHubPane/GitHubPaneViewModel.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,35 @@ public GitHubPaneViewModel(
8585
this.notAGitHubRepository = notAGitHubRepository;
8686
this.notAGitRepository = notAGitRepository;
8787

88-
// Returns navigator.Current if Content == navigator, otherwise null.
89-
var currentPage = Observable.CombineLatest(
88+
var contentAndNavigatorContent = Observable.CombineLatest(
9089
this.WhenAnyValue(x => x.Content),
91-
navigator.WhenAnyValue(x => x.Content))
92-
.Select(x => x[0] == navigator ? x[1] as IPanePageViewModel : null);
90+
navigator.WhenAnyValue(x => x.Content),
91+
(c, nc) => new { Content = c, NavigatorContent = nc });
9392

94-
contentOverride = currentPage
95-
.SelectMany(x => x?.WhenAnyValue(y => y.IsLoading, y => y.Error) ??
96-
Observable.Return<Tuple<bool, Exception>>(null))
97-
.Select(x =>
93+
contentOverride = contentAndNavigatorContent
94+
.SelectMany(x =>
9895
{
99-
if (x == null || x.Item1) return ContentOverride.Spinner;
100-
else if (x.Item2 != null) return ContentOverride.Error;
101-
else return ContentOverride.None;
96+
if (x.Content == null) return Observable.Return(ContentOverride.Spinner);
97+
else if (x.Content == navigator && x.NavigatorContent != null)
98+
{
99+
return x.NavigatorContent.WhenAnyValue(
100+
y => y.IsLoading,
101+
y => y.Error,
102+
(l, e) =>
103+
{
104+
if (l) return ContentOverride.Spinner;
105+
if (e != null) return ContentOverride.Error;
106+
else return ContentOverride.None;
107+
});
108+
}
109+
else return Observable.Return(ContentOverride.None);
102110
})
103111
.ToProperty(this, x => x.ContentOverride);
104112

113+
// Returns navigator.Content if Content == navigator, otherwise null.
114+
var currentPage = contentAndNavigatorContent
115+
.Select(x => x.Content == navigator ? x.NavigatorContent : null);
116+
105117
title = currentPage
106118
.SelectMany(x => x?.WhenAnyValue(y => y.Title) ?? Observable.Return<string>(null))
107119
.Select(x => x ?? "GitHub")
@@ -331,6 +343,8 @@ async Task UpdateContent(ILocalRepositoryModel repository)
331343
LocalRepository = repository;
332344
Connection = null;
333345

346+
Content = null;
347+
334348
if (repository == null)
335349
{
336350
Content = notAGitRepository;

0 commit comments

Comments
 (0)