From 828b0a2e2199b310d7a91308e2268f185d15979b Mon Sep 17 00:00:00 2001 From: Debug <49997488+DebugOk@users.noreply.github.com> Date: Sat, 14 Oct 2023 22:14:14 +0200 Subject: [PATCH] Revert "Update changelog system (#75)" This reverts commit 38ee8f45bdac76e8833c673abc4425f76c027c61. --- Content.Client/Changelog/ChangelogManager.cs | 51 +++++-------------- .../Changelog/ChangelogWindow.xaml.cs | 7 +-- Tools/actions_changelogs_since_last_run.py | 4 +- 3 files changed, 16 insertions(+), 46 deletions(-) diff --git a/Content.Client/Changelog/ChangelogManager.cs b/Content.Client/Changelog/ChangelogManager.cs index 0d9ab6f0201..249332c337f 100644 --- a/Content.Client/Changelog/ChangelogManager.cs +++ b/Content.Client/Changelog/ChangelogManager.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Text.RegularExpressions; using System.Threading.Tasks; using Content.Shared.CCVar; using Robust.Shared.Configuration; @@ -26,8 +25,8 @@ namespace Content.Client.Changelog [Dependency] private readonly IConfigurationManager _configManager = default!; public bool NewChangelogEntries { get; private set; } - public DateTime LastReadTime { get; private set; } // Modified, see EOF - public DateTime MaxTime { get; private set; } // Modified, see EOF + public int LastReadId { get; private set; } + public int MaxId { get; private set; } public event Action? NewChangelogEntriesChanged; @@ -36,7 +35,7 @@ namespace Content.Client.Changelog /// stores the new ID to disk and clears . /// /// - /// is NOT cleared + /// is NOT cleared /// since that's used in the changelog menu to show the "since you last read" bar. /// public void SaveNewReadId() @@ -44,9 +43,9 @@ namespace Content.Client.Changelog NewChangelogEntries = false; NewChangelogEntriesChanged?.Invoke(); - using var sw = _resource.UserData.OpenWriteText(new ($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}_datetime")); // Modified, see EOF + using var sw = _resource.UserData.OpenWriteText(new ($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}")); - sw.Write(MaxTime.ToString("O")); // Modified, see EOF + sw.Write(MaxId.ToString()); } public async void Initialize() @@ -59,46 +58,24 @@ namespace Content.Client.Changelog return; } - MaxTime = changelog.Max(c => c.Time); // Modified, see EOF + MaxId = changelog.Max(c => c.Id); - // Begin modified codeblock, see EOF - var path = new ResPath($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}_datetime"); - if(_resource.UserData.TryReadAllText(path, out var lastReadTimeText)) + var path = new ResPath($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}"); + if(_resource.UserData.TryReadAllText(path, out var lastReadIdText)) { - if (Regex.IsMatch(lastReadTimeText, - @"^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$")) - { - LastReadTime = DateTime.ParseExact(lastReadTimeText, "O", CultureInfo.InvariantCulture); - } + LastReadId = int.Parse(lastReadIdText); } - NewChangelogEntries = LastReadTime < MaxTime; - // End modified codeblock + NewChangelogEntries = LastReadId < MaxId; NewChangelogEntriesChanged?.Invoke(); } - // Begin modified codeblock, see EOF - public async Task> LoadChangelog() - { - var paths = _resource.ContentFindFiles("/Changelog/") - .Where(filePath => filePath.Extension == "yml") - .ToArray(); - - var result = new List(); - foreach (var path in paths) - { - var changelog = await LoadChangelogFile(path); - result = result.Union(changelog).ToList(); - } - return result.OrderBy(x => x.Time).ToList(); - } - - private Task> LoadChangelogFile(ResPath path) // end modified codeblock + public Task> LoadChangelog() { return Task.Run(() => { - var yamlData = _resource.ContentFileReadYaml(path); // Modified, see EOF + var yamlData = _resource.ContentFileReadYaml(new ("/Changelog/Changelog.yml")); if (yamlData.Documents.Count == 0) return new List(); @@ -149,7 +126,3 @@ namespace Content.Client.Changelog } } } - - -// This file was extensively modified to allow for datetime based changelogs instead of relying on IDs. -// This is because our IDs are much lower then Wizdens, and if we use their entries, the server will not properly show new changes diff --git a/Content.Client/Changelog/ChangelogWindow.xaml.cs b/Content.Client/Changelog/ChangelogWindow.xaml.cs index 9c3da72ffbf..cea5bd9e7c2 100644 --- a/Content.Client/Changelog/ChangelogWindow.xaml.cs +++ b/Content.Client/Changelog/ChangelogWindow.xaml.cs @@ -48,13 +48,13 @@ namespace Content.Client.Changelog .GroupBy(e => e.Time.ToLocalTime().Date) .OrderByDescending(c => c.Key); - var hasRead = _changelog.MaxTime <= _changelog.LastReadTime; // Modified, see EOF + var hasRead = _changelog.MaxId <= _changelog.LastReadId; foreach (var dayEntries in byDay) { var day = dayEntries.Key; var groupedEntries = dayEntries - .GroupBy(c => (c.Author, Read: c.Time <= _changelog.LastReadTime)) // Modified, see EOF + .GroupBy(c => (c.Author, Read: c.Id <= _changelog.LastReadId)) .OrderBy(c => c.Key.Read) .ThenBy(c => c.Key.Author); @@ -203,6 +203,3 @@ namespace Content.Client.Changelog } } } - -// This file was extensively modified to allow for datetime based changelogs instead of relying on IDs. -// This is because our IDs are much lower then Wizdens, and if we use their entries, the server will not properly show new changes diff --git a/Tools/actions_changelogs_since_last_run.py b/Tools/actions_changelogs_since_last_run.py index a2501753a67..0c46cd22ec8 100755 --- a/Tools/actions_changelogs_since_last_run.py +++ b/Tools/actions_changelogs_since_last_run.py @@ -19,7 +19,7 @@ GITHUB_TOKEN = os.environ["GITHUB_TOKEN"] DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL") -CHANGELOG_FILE = "Resources/Changelog/DeltaVChangelog.yml" +CHANGELOG_FILE = "Resources/Changelog/Changelog.yml" TYPES_TO_EMOJI = { "Fix": "🐛", @@ -130,4 +130,4 @@ def send_to_discord(entries: Iterable[ChangelogEntry]) -> None: requests.post(DISCORD_WEBHOOK_URL, json=body) -main() +main() \ No newline at end of file