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

Commit 9e4d1e2

Browse files
committed
Simplify the IsSectionVisible code
1 parent 5690b6f commit 9e4d1e2

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/GitHub.VisualStudio.16/Sync/PublishSection.cs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,16 @@ void Section_PropertyChanged(object sender, PropertyChangedEventArgs e)
127127

128128
void RefreshVisibility()
129129
{
130-
var visible = false;
131-
132-
if (ServiceProvider.GetService(typeof(ITeamExplorerPage)) is ITeamExplorerPage page)
133-
{
134-
visible = IsSectionVisible(page, PushToRemoteSectionId);
135-
}
136-
137-
if (IsVisible != visible)
130+
var isVisible = IsSectionVisible(PushToRemoteSectionId);
131+
if (IsVisible != isVisible)
138132
{
139-
if (visible)
133+
if (isVisible)
140134
{
141-
// Don't initialize the view until it becomes visible
135+
// Initialize the view when it becomes visible
142136
EnsureSectionInitialized();
143137
}
144138

145-
IsVisible = visible;
139+
IsVisible = isVisible;
146140
}
147141
}
148142

@@ -162,14 +156,10 @@ void EnsureSectionInitialized()
162156
}
163157
}
164158

165-
bool IsSectionVisible(ITeamExplorerPage teamExplorerPage, Guid sectionId)
166-
{
167-
if (teamExplorerPage.GetSection(sectionId) is ITeamExplorerSection pushToRemoteSection)
168-
{
169-
return pushToRemoteSection.SectionContent != null && pushToRemoteSection.IsVisible;
170-
}
171-
172-
return false;
173-
}
159+
bool IsSectionVisible(Guid sectionId) =>
160+
ServiceProvider.GetService(typeof(ITeamExplorerPage)) is ITeamExplorerPage page &&
161+
page.GetSection(sectionId) is ITeamExplorerSection section &&
162+
section.SectionContent != null &&
163+
section.IsVisible;
174164
}
175165
}

0 commit comments

Comments
 (0)