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

Commit ac41d5b

Browse files
committed
Don't load the publish view until is becomes visible
1 parent 6e798c6 commit ac41d5b

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

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

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ public class PublishSection : TeamExplorerBaseSection
3737
public PublishSection(CompositionServices compositionServices)
3838
{
3939
this.compositionServices = compositionServices;
40-
41-
this.Title = "Publish to GitHub";
42-
this.IsExpanded = true;
43-
this.IsBusy = false;
44-
this.SectionContent = new PublishView(){
45-
DataContext = this
46-
};
47-
this.View.ParentSection = this;
4840
}
4941

5042
/// <summary>
@@ -83,10 +75,10 @@ public override void Initialize(object sender, SectionInitializeEventArgs e)
8375
}
8476
}
8577

86-
PublishToGitHub = new RelayCommand(o => ShowPublishDialog().Forget());
78+
PublishToGitHub = new RelayCommand(o => ShowPublishDialogAsync().Forget());
8779
}
8880

89-
async Task ShowPublishDialog()
81+
async Task ShowPublishDialogAsync()
9082
{
9183
var exportProvider = compositionServices.GetExportProvider();
9284

@@ -153,10 +145,34 @@ void RefreshVisibility()
153145

154146
if (IsVisible != visible)
155147
{
148+
if (visible)
149+
{
150+
// Don't initialize the view until it becomes visible
151+
EnsureSectionInitialized();
152+
}
153+
156154
IsVisible = visible;
157155
}
158156
}
159157

158+
void EnsureSectionInitialized()
159+
{
160+
if (SectionContent == null)
161+
{
162+
Title = "Publish to GitHub";
163+
IsExpanded = true;
164+
IsBusy = false;
165+
166+
Assumes.NotNull(GitHub.Resources.BlurbText); // Ensure GitHub.Resourcess has been loaded before we use it from XAML
167+
SectionContent = new PublishView()
168+
{
169+
DataContext = this
170+
};
171+
172+
View.ParentSection = this;
173+
}
174+
}
175+
160176
bool IsSectionVisible(ITeamExplorerPage teamExplorerPage, Guid sectionId)
161177
{
162178
if (teamExplorerPage.GetSection(sectionId) is ITeamExplorerSection pushToRemoteSection)

0 commit comments

Comments
 (0)