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

Commit e5065bc

Browse files
committed
Merge branch 'master' into fixes/809-refactor-logins
Conflicts: src/GitHub.App/Models/RepositoryHost.cs
2 parents 47835d7 + c7f35bc commit e5065bc

File tree

10 files changed

+54
-57
lines changed

10 files changed

+54
-57
lines changed

src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ public override void Initialize([AllowNull] ViewWithData data)
286286
/// <param name="files">The pull request's changed files.</param>
287287
public async Task Load(IPullRequestModel pullRequest)
288288
{
289+
var firstLoad = (Model == null);
289290
Model = pullRequest;
290291
Title = Resources.PullRequestNavigationItemText + " #" + pullRequest.Number;
291292

@@ -298,7 +299,6 @@ public async Task Load(IPullRequestModel pullRequest)
298299
ChangedFilesTree = CreateChangedFilesTree(pullRequest, changes).Children.ToList();
299300

300301
var localBranches = await pullRequestsService.GetLocalBranches(repository, pullRequest).ToList();
301-
302302
IsCheckedOut = localBranches.Contains(repository.CurrentBranch);
303303

304304
if (IsCheckedOut)
@@ -363,6 +363,11 @@ public async Task Load(IPullRequestModel pullRequest)
363363

364364
IsLoading = IsBusy = false;
365365

366+
if (firstLoad)
367+
{
368+
usageTracker.IncrementPullRequestOpened().Forget();
369+
}
370+
366371
if (!isInCheckout)
367372
{
368373
pullRequestsService.RemoveUnusedRemotes(repository).Subscribe(_ => { });
@@ -480,7 +485,6 @@ IObservable<Unit> DoCheckout(object unused)
480485
return Observable.Defer(async () =>
481486
{
482487
var localBranches = await pullRequestsService.GetLocalBranches(repository, Model).ToList();
483-
484488
if (localBranches.Count > 0)
485489
{
486490
return pullRequestsService.SwitchToBranch(repository, Model);

src/GitHub.Exports/Services/IUsageTracker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public interface IUsageTracker
1919
Task IncrementPullRequestCheckOutCount(bool fork);
2020
Task IncrementPullRequestPullCount(bool fork);
2121
Task IncrementPullRequestPushCount(bool fork);
22+
Task IncrementPullRequestOpened();
2223
Task IncrementWelcomeDocsClicks();
2324
Task IncrementWelcomeTrainingClicks();
2425
Task IncrementGitHubPaneHelpClicks();

src/GitHub.TeamFoundation.14/Home/GitHubHomeSection.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class GitHubHomeSection : TeamExplorerSectionBase, IGitHubHomeSection
2626
{
2727
public const string GitHubHomeSectionId = "72008232-2104-4FA0-A189-61B0C6F91198";
2828
const string TrainingUrl = "https://services.github.com/on-demand/windows/visual-studio";
29+
readonly static Guid welcomeMessageGuid = new Guid(Guids.TeamExplorerWelcomeMessage);
2930

3031
readonly IVisualStudioBrowser visualStudioBrowser;
3132
readonly ITeamExplorerServices teamExplorerServices;
@@ -53,25 +54,6 @@ public GitHubHomeSection(IGitHubServiceProvider serviceProvider,
5354
var openOnGitHub = ReactiveCommand.Create();
5455
openOnGitHub.Subscribe(_ => DoOpenOnGitHub());
5556
OpenOnGitHub = openOnGitHub;
56-
57-
// We want to display a welcome message but only if Team Explorer isn't
58-
// already displaying the "Install 3rd Party Tools" message. To do this
59-
// we need to set a timer and check in the tick as at this point the message
60-
// won't be initialized.
61-
if (!settings.HideTeamExplorerWelcomeMessage)
62-
{
63-
var timer = new DispatcherTimer();
64-
timer.Interval = new TimeSpan(10);
65-
timer.Tick += (s, e) =>
66-
{
67-
timer.Stop();
68-
if (!IsGitToolsMessageVisible())
69-
{
70-
ShowWelcomeMessage();
71-
}
72-
};
73-
timer.Start();
74-
}
7557
}
7658

7759
bool IsGitToolsMessageVisible()
@@ -93,12 +75,24 @@ protected async override void RepoChanged(bool changed)
9375
RepoName = ActiveRepoName;
9476
RepoUrl = ActiveRepoUri.ToString();
9577
Icon = GetIcon(false, true, false);
78+
79+
// We want to display a welcome message but only if Team Explorer isn't
80+
// already displaying the "Install 3rd Party Tools" message and the current repo is hosted on GitHub.
81+
if (!settings.HideTeamExplorerWelcomeMessage && !IsGitToolsMessageVisible())
82+
{
83+
ShowWelcomeMessage();
84+
}
85+
9686
Debug.Assert(SimpleApiClient != null,
9787
"If we're in this block, simpleApiClient cannot be null. It was created by UpdateStatus");
9888
var repo = await SimpleApiClient.GetRepository();
9989
Icon = GetIcon(repo.Private, true, repo.Fork);
10090
IsLoggedIn = await IsUserAuthenticated();
10191
}
92+
else
93+
{
94+
teamExplorerServices.HideNotification(welcomeMessageGuid);
95+
}
10296
}
10397

10498
public override async void Refresh()
@@ -108,6 +102,7 @@ public override async void Refresh()
108102
{
109103
IsLoggedIn = await IsUserAuthenticated();
110104
}
105+
111106
base.Refresh();
112107
}
113108

@@ -149,7 +144,6 @@ void DoOpenOnGitHub()
149144

150145
void ShowWelcomeMessage()
151146
{
152-
var welcomeMessageGuid = new Guid(Guids.TeamExplorerWelcomeMessage);
153147
teamExplorerServices.ShowMessage(
154148
Resources.TeamExplorerWelcomeMessage,
155149
new RelayCommand(o =>

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<BuildType Condition="Exists('..\..\script\src\ApiClientConfiguration_User.cs')">Internal</BuildType>
2323
<ApplicationVersion>2.2.0.7</ApplicationVersion>
2424
<BuildType Condition="Exists('..\..\script\src\ApiClientConfiguration.cs')">Internal</BuildType>
25-
<ApplicationVersion>2.2.0.11</ApplicationVersion>
25+
<ApplicationVersion>2.3.0.0</ApplicationVersion>
2626
<OutputPath>..\..\build\$(Configuration)\</OutputPath>
2727
<VsixType>v3</VsixType>
2828
<IsProductComponent>false</IsProductComponent>
@@ -738,4 +738,4 @@
738738
<Target Name="AfterBuild">
739739
</Target>
740740
-->
741-
</Project>
741+
</Project>

src/GitHub.VisualStudio/Services/UsageTracker.cs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111
using GitHub.Extensions;
1212
using System.Threading.Tasks;
1313
using GitHub.Helpers;
14+
using System.Threading;
1415

1516
namespace GitHub.Services
1617
{
17-
public class UsageTracker : IUsageTracker
18+
public sealed class UsageTracker : IUsageTracker, IDisposable
1819
{
1920
const string StoreFileName = "ghfvs.usage";
2021
static readonly Calendar cal = CultureInfo.InvariantCulture.Calendar;
2122

2223
readonly IGitHubServiceProvider gitHubServiceProvider;
23-
readonly DispatcherTimer timer;
24-
2524
IMetricsService client;
2625
IConnectionManager connectionManager;
2726
IPackageSettings userSettings;
2827
IVSServices vsservices;
28+
Timer timer;
2929
string storePath;
3030
bool firstRun = true;
3131

@@ -61,13 +61,16 @@ public UsageTracker(IGitHubServiceProvider gitHubServiceProvider)
6161
};
6262
dirCreate = (path) => System.IO.Directory.CreateDirectory(path);
6363

64-
this.timer = new DispatcherTimer(
65-
TimeSpan.FromMinutes(3),
66-
DispatcherPriority.Background,
64+
this.timer = new Timer(
6765
TimerTick,
68-
ThreadingHelper.MainThreadDispatcher);
66+
null,
67+
TimeSpan.FromMinutes(3),
68+
TimeSpan.FromHours(8));
69+
}
6970

70-
RunTimer();
71+
public void Dispose()
72+
{
73+
timer?.Dispose();
7174
}
7275

7376
public async Task IncrementLaunchCount()
@@ -192,6 +195,13 @@ public async Task IncrementGitHubPaneHelpClicks()
192195
SaveUsage(usage);
193196
}
194197

198+
public async Task IncrementPullRequestOpened()
199+
{
200+
var usage = await LoadUsage();
201+
++usage.Model.NumberOfPullRequestsOpened;
202+
SaveUsage(usage);
203+
}
204+
195205
async Task Initialize()
196206
{
197207
// The services needed by the usage tracker are loaded when they are first needed to
@@ -244,14 +254,7 @@ void SaveUsage(UsageStore store)
244254
writeAllText(storePath, json, Encoding.UTF8);
245255
}
246256

247-
void RunTimer()
248-
{
249-
// The timer first ticks after 3 minutes to allow things to settle down after startup.
250-
// This will be changed to 8 hours after the first tick by the TimerTick method.
251-
timer.Start();
252-
}
253-
254-
void TimerTick(object sender, EventArgs e)
257+
void TimerTick(object state)
255258
{
256259
TimerTick()
257260
.Catch(ex =>
@@ -268,13 +271,13 @@ async Task TimerTick()
268271
if (firstRun)
269272
{
270273
await IncrementLaunchCount();
271-
timer.Interval = TimeSpan.FromHours(8);
272274
firstRun = false;
273275
}
274276

275277
if (client == null || !userSettings.CollectMetrics)
276278
{
277-
timer.Stop();
279+
timer.Dispose();
280+
timer = null;
278281
return;
279282
}
280283

@@ -350,6 +353,9 @@ static void ClearCounters(UsageModel usage, bool weekly, bool monthly)
350353
usage.NumberOfForkPullRequestsCheckedOut = 0;
351354
usage.NumberOfForkPullRequestPulls = 0;
352355
usage.NumberOfForkPullRequestPushes = 0;
356+
usage.NumberOfGitHubPaneHelpClicks = 0;
357+
usage.NumberOfWelcomeTrainingClicks = 0;
358+
usage.NumberOfWelcomeDocsClicks = 0;
353359

354360
if (weekly)
355361
usage.NumberOfStartupsWeek = 0;

src/GitHub.VisualStudio/Services/UsageTrackerDispatcher.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public UsageTrackerDispatcher([Import(typeof(SVsServiceProvider))] IServiceProvi
2626
public Task IncrementOpenInGitHubCount() => inner.IncrementOpenInGitHubCount();
2727
public Task IncrementPublishCount() => inner.IncrementPublishCount();
2828
public Task IncrementUpstreamPullRequestCount() => inner.IncrementUpstreamPullRequestCount();
29+
public Task IncrementPullRequestOpened() => inner.IncrementPullRequestOpened();
2930
public Task IncrementPullRequestCheckOutCount(bool fork) => inner.IncrementPullRequestCheckOutCount(fork);
3031
public Task IncrementPullRequestPullCount(bool fork) => inner.IncrementPullRequestPullCount(fork);
3132
public Task IncrementPullRequestPushCount(bool fork) => inner.IncrementPullRequestPushCount(fork);

src/GitHub.VisualStudio/UI/Views/Controls/RepositoryCloneControl.xaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@
155155
IsEnabled="{Binding FilterTextIsEnabled, Mode=OneWay}"
156156
AutomationProperties.AutomationId="{x:Static automation:AutomationIDs.SearchRepositoryTextBox}" />
157157

158-
<ui:GitHubProgressBar x:Name="loadingProgressBar"
159-
Margin="0"
160-
HorizontalContentAlignment="Stretch"
161-
DockPanel.Dock="Top"
162-
Foreground="{DynamicResource GitHubAccentBrush}"
163-
IsIndeterminate="True"
164-
Style="{DynamicResource GitHubProgressBar}"
165-
Visibility="{Binding IsBusy, Mode=OneWay, Converter={ui:BooleanToVisibilityConverter}}" />
166-
167158
<StackPanel x:Name="loadingFailedPanel"
168159
Margin="0,4,0,4"
169160
HorizontalAlignment="Center"

src/GitHub.VisualStudio/source.extension.vsixmanifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.2.0.11" Language="en-US" Publisher="GitHub, Inc" />
4+
<Identity Id="c3d3dc68-c977-411f-b3e8-03b0dccf7dfc" Version="2.3.0.0" Language="en-US" Publisher="GitHub, Inc" />
55
<DisplayName>GitHub Extension for Visual Studio</DisplayName>
66
<Description xml:space="preserve">A Visual Studio Extension that brings the GitHub Flow into Visual Studio.</Description>
77
<PackageId>GitHub.VisualStudio</PackageId>
@@ -11,7 +11,7 @@
1111
<PreviewImage>Resources\preview_200x200.png</PreviewImage>
1212
<Tags>GitHub;git;open source;source control;branch;pull request;team explorer;commit;publish</Tags>
1313
</Metadata>
14-
<Installation AllUsers="true" Experimental="true">
14+
<Installation AllUsers="false" Experimental="true">
1515
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0,15.0]" />
1616
</Installation>
1717
<Dependencies>

src/MsiInstaller/Version.wxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Include>
3-
<?define VersionNumber="2.2.0.11" ?>
3+
<?define VersionNumber="2.3.0.0" ?>
44
</Include>

src/common/SolutionInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using System.Runtime.InteropServices;
44

55
[assembly: AssemblyProduct("GitHub Extension for Visual Studio")]
6-
[assembly: AssemblyVersion("2.2.0.11")]
7-
[assembly: AssemblyFileVersion("2.2.0.11")]
6+
[assembly: AssemblyVersion("2.3.0.0")]
7+
[assembly: AssemblyFileVersion("2.3.0.0")]
88
[assembly: ComVisible(false)]
99
[assembly: AssemblyCompany("GitHub, Inc.")]
1010
[assembly: AssemblyCopyright("Copyright © GitHub, Inc. 2014-2016")]
@@ -16,6 +16,6 @@
1616
namespace System
1717
{
1818
internal static class AssemblyVersionInformation {
19-
internal const string Version = "2.2.0.11";
19+
internal const string Version = "2.3.0.0";
2020
}
2121
}

0 commit comments

Comments
 (0)