Skip to content

Commit

Permalink
Update PreviouslySeenVersion and Shown
Browse files Browse the repository at this point in the history
- should fix #1317 (comment)
  • Loading branch information
originalfoo committed Jan 26, 2022
1 parent beb810e commit 0f15f0c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions TLM/TLM/UI/WhatsNew/WhatsNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,33 @@ public class WhatsNew {
// bump and update what's new changelogs when new features added
internal static readonly Version CurrentVersion = new Version(11,6,4,1);

internal static readonly Version PreviouslySeenVersion = GlobalConfig.Instance.Main.LastWhatsNewPanelVersion;

internal bool Shown => PreviouslySeenVersion >= CurrentVersion;

private const string WHATS_NEW_FILE = "whats_new.txt";
private const string RESOURCES_PREFIX = "TrafficManager.Resources.";

public WhatsNew() {
LoadChangelogs();
}

public static Version PreviouslySeenVersion {
get => GlobalConfig.Instance.Main.LastWhatsNewPanelVersion;
set {
if (value > GlobalConfig.Instance.Main.LastWhatsNewPanelVersion) {
Log.Info($"What's New: LastWhatsNewPanelVersion = {value}");
GlobalConfig.Instance.Main.LastWhatsNewPanelVersion = value;
GlobalConfig.WriteConfig();
}
}
}

public bool Shown => PreviouslySeenVersion >= CurrentVersion;

public List<Changelog> Changelogs { get; private set; }

public static void OpenModal() {
UIView uiView = UIView.GetAView();
if (uiView) {
MarkAsShown();

WhatsNewPanel panel = uiView.AddUIComponent(typeof(WhatsNewPanel)) as WhatsNewPanel;
if (panel) {
Log.Info("Opened What's New panel!");
Expand All @@ -46,8 +56,7 @@ public static void OpenModal() {

public static void MarkAsShown() {
Log.Info($"What's New - mark as shown. Version {CurrentVersion}");
GlobalConfig.Instance.Main.LastWhatsNewPanelVersion = CurrentVersion;
GlobalConfig.WriteConfig();
PreviouslySeenVersion = CurrentVersion;
}

private void LoadChangelogs() {
Expand Down

0 comments on commit 0f15f0c

Please sign in to comment.