Skip to content

Commit 7c45728

Browse files
committed
Correction for stats
1 parent 70ae347 commit 7c45728

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CodeStats/CodeStatsPackage.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CodeStatsPackage
4040
public static bool Stats;
4141
public static string Guid;
4242

43+
public static bool _reportedStats = false;
44+
4345
//public static string currentLangName = ""; // N++ (ex. HTML, not compatible with Code::Stats names everywhere)
4446
public static string currentLangDesc = ""; // N++ (ex. Hyper Text Markup Language)
4547
public static string currentLanguage = ""; // Code::Stats
@@ -175,7 +177,7 @@ private static void InitializeAsync()
175177

176178
if (Stats)
177179
{
178-
StatsReport();
180+
ReportStats();
179181
}
180182

181183
Logger.Info(string.Format("Finished initializing Code::Stats v{0}", Constants.PluginVersion));
@@ -569,10 +571,11 @@ private static void SettingsPopup()
569571
_settingsForm.ShowDialog();
570572
}
571573

572-
private static void StatsReport()
574+
public static void ReportStats()
573575
{
574576
var client = new WebClient { Proxy = CodeStatsPackage.GetProxy() };
575577
string HtmlResult = client.DownloadString("https://p0358.cf/codestats/report.php?pluginver=" + Constants.PluginVersion + "&cid=" + CodeStatsPackage.Guid); // expected response: ok
578+
if (HtmlResult.Contains("ok")) _reportedStats = true;
576579
}
577580

578581
private static string ToUnixEpoch(DateTime date)

CodeStats/Forms/SettingsForm.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ private void btnOk_Click(object sender, EventArgs e)
4545
_CodeStatsConfigFile.Debug = chkDebugMode.Checked;
4646
_CodeStatsConfigFile.Stats = chkStats.Checked;
4747
_CodeStatsConfigFile.Save();
48-
OnConfigSaved();
48+
49+
if (chkStats.Checked && !CodeStatsPackage._reportedStats)
50+
{
51+
CodeStatsPackage.ReportStats();
52+
}
53+
54+
OnConfigSaved();
4955
}
5056
else
5157
{

0 commit comments

Comments
 (0)