Skip to content

Commit 6d52975

Browse files
committed
Show the release history in the extension update message box for each released version
1 parent 236209e commit 6d52975

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

VisualStudioDiscordRPC.Shared/PackageController.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using VisualStudioDiscordRPC.Shared.Nests;
1717
using VisualStudioDiscordRPC.Shared.Utils;
1818
using Newtonsoft.Json;
19+
using System.Collections.Generic;
1920

2021
namespace VisualStudioDiscordRPC.Shared
2122
{
@@ -54,7 +55,7 @@ public void Init()
5455

5556
if (updateNotificationsEnabled)
5657
{
57-
DisplayVersionUpdateMessage(currentExtensionVersion);
58+
DisplayVersionUpdateMessage(previousVersion, currentExtensionVersion);
5859
}
5960
}
6061
}
@@ -146,42 +147,47 @@ private void ApplySettings()
146147
_discordRpcController.SetPlug<SecondButtonNest>(_plugService.GetPlugById<BaseButtonPlug>(secondButtonPlug));
147148
}
148149

149-
private void DisplayVersionUpdateMessage(string version)
150+
private void DisplayVersionUpdateMessage(string previousVersion, string currentVersion)
150151
{
152+
var releaseNotes = ReadReleaseNotesOfVersionRange(previousVersion, currentVersion);
151153
var updateTextBuilder = new StringBuilder();
152-
updateTextBuilder.AppendLine(string.Format(ConstantStrings.NewVersionNotification, version));
153154

154-
ReleaseNote currentVersionReleaseNote = ReadReleaseNoteOfVersion(version);
155-
if (currentVersionReleaseNote != null)
155+
updateTextBuilder.AppendLine(string.Format(ConstantStrings.NewVersionNotification, currentVersion));
156+
157+
foreach (var releaseNote in releaseNotes)
156158
{
157159
updateTextBuilder.AppendLine();
158-
updateTextBuilder.AppendLine("Release notes: ");
160+
updateTextBuilder.AppendLine($"Release notes of {releaseNote.Version}:");
159161

160-
string notesText = string.Join("\n",
161-
currentVersionReleaseNote.Notes.Select(note => $" - {note}"));
162+
string notesText = string.Join("\n",
163+
releaseNote.Notes.Select(note => $" - {note}"));
162164
updateTextBuilder.AppendLine(notesText);
163165
}
164166

165167
MessageBox.Show(updateTextBuilder.ToString(), "Visual Studio Discord RPC Update",
166168
MessageBoxButton.OK, MessageBoxImage.Information);
167169
}
168170

169-
private ReleaseNote ReadReleaseNoteOfVersion(string version)
171+
private List<ReleaseNote> ReadReleaseNotesOfVersionRange(string startVersionString, string endVersionString)
170172
{
173+
var result = new List<ReleaseNote>();
174+
171175
string releaseNotePath = PathHelper.GetPackageInstallationPath("RELEASE_NOTES.txt");
172176
string releaseNotesText = File.ReadAllText(releaseNotePath);
173177

174178
var releaseNotesParser = new ReleaseNotesParser(releaseNotesText);
175179

180+
var startVersion = new Version(startVersionString);
181+
var endVersion = new Version(endVersionString);
182+
176183
while (releaseNotesParser.ReadReleaseNote(out ReleaseNote releaseNote))
177184
{
178-
if (releaseNote.Version == version)
179-
{
180-
return releaseNote;
181-
}
185+
var version = new Version(releaseNote.Version);
186+
if (version > startVersion && version <= endVersion)
187+
result.Add(releaseNote);
182188
}
183189

184-
return null;
190+
return result;
185191
}
186192
}
187193
}

0 commit comments

Comments
 (0)