Skip to content

Commit b23fe16

Browse files
committed
Do not show the udpate message for the first time
1 parent d5cefe1 commit b23fe16

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

VisualStudioDiscordRPC.Shared/PackageController.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,7 @@ public void Init()
4242
_repositorySecrecyService.Start();
4343

4444
ApplySettings();
45-
46-
string currentExtensionVersion = VisualStudioHelper.GetExtensionVersion();
47-
bool updateNotificationsEnabled = _settingsService.Read<bool>(SettingsKeys.UpdateNotifications);
48-
49-
string previousVersion = _settingsService.Read<string>(SettingsKeys.Version);
50-
51-
if (currentExtensionVersion != previousVersion)
52-
{
53-
_settingsService.Set(SettingsKeys.Version, currentExtensionVersion);
54-
_settingsService.Save();
55-
56-
if (updateNotificationsEnabled)
57-
{
58-
DisplayVersionUpdateMessage(previousVersion, currentExtensionVersion);
59-
}
60-
}
45+
TryShowUpdateMessage();
6146
}
6247

6348
public void Clear()
@@ -147,6 +132,31 @@ private void ApplySettings()
147132
_discordRpcController.SetPlug<SecondButtonNest>(_plugService.GetPlugById<BaseButtonPlug>(secondButtonPlug));
148133
}
149134

135+
private void TryShowUpdateMessage()
136+
{
137+
string currentExtensionVersion = VisualStudioHelper.GetExtensionVersion();
138+
bool updateNotificationsEnabled = _settingsService.Read<bool>(SettingsKeys.UpdateNotifications);
139+
140+
string previousVersion = _settingsService.Read<string>(SettingsKeys.Version);
141+
142+
if (currentExtensionVersion != previousVersion)
143+
{
144+
_settingsService.Set(SettingsKeys.Version, currentExtensionVersion);
145+
_settingsService.Save();
146+
147+
if (string.IsNullOrEmpty(previousVersion) || previousVersion == SettingsDefaults.DefaultVersion)
148+
{
149+
// Do not show the update message for the first time.
150+
return;
151+
}
152+
153+
if (updateNotificationsEnabled)
154+
{
155+
DisplayVersionUpdateMessage(previousVersion, currentExtensionVersion);
156+
}
157+
}
158+
}
159+
150160
private void DisplayVersionUpdateMessage(string previousVersion, string currentVersion)
151161
{
152162
var releaseNotes = ReadReleaseNotesOfVersionRange(previousVersion, currentVersion);

VisualStudioDiscordRPC.Shared/SettingsDefaults.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
public static class SettingsDefaults
44
{
55
public const long DefaultIdleTime = 5;
6+
public const string DefaultVersion = "1.0.0";
67
}
78
}

0 commit comments

Comments
 (0)