From 8dd24de0c063b70fbc2e6a9e2d6a08056e3af4dd Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 28 Oct 2022 22:44:06 +1100 Subject: [PATCH] update category strings to constants --- Flow.Launcher/Converters/TextConverter.cs | 21 +++++-------------- .../ViewModel/PluginStoreItemViewModel.cs | 17 +++++++++------ .../ViewModel/SettingWindowViewModel.cs | 15 ++++--------- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/Flow.Launcher/Converters/TextConverter.cs b/Flow.Launcher/Converters/TextConverter.cs index 905b728a3..90d445776 100644 --- a/Flow.Launcher/Converters/TextConverter.cs +++ b/Flow.Launcher/Converters/TextConverter.cs @@ -1,13 +1,8 @@ using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; using System.Windows.Data; using Flow.Launcher.Core.Resource; +using Flow.Launcher.ViewModel; namespace Flow.Launcher.Converters { @@ -18,23 +13,17 @@ namespace Flow.Launcher.Converters var ID = value.ToString(); switch(ID) { - case "NewRelease": + case PluginStoreItemViewModel.NewRelease: return InternationalizationManager.Instance.GetTranslation("pluginStore_NewRelease"); - break; - case "RecentlyUpdated": + case PluginStoreItemViewModel.RecentlyUpdated: return InternationalizationManager.Instance.GetTranslation("pluginStore_RecentlyUpdated"); - break; - case "None": + case PluginStoreItemViewModel.None: return InternationalizationManager.Instance.GetTranslation("pluginStore_None"); - break; - case "installed": + case PluginStoreItemViewModel.Installed: return InternationalizationManager.Instance.GetTranslation("pluginStore_Installed"); - break; default: return ID; - break; } - } diff --git a/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs b/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs index ad2e58d9a..622e41b1b 100644 --- a/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs +++ b/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using Flow.Launcher.Core.ExternalPlugins; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Plugin; @@ -27,23 +26,29 @@ namespace Flow.Launcher.ViewModel public string IcoPath => _plugin.IcoPath; public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null; - public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version; + public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version; + + internal const string None = "None"; + internal const string RecentlyUpdated = "RecentlyUpdated"; + internal const string NewRelease = "NewRelease"; + internal const string Installed = "Installed"; + public string Category { get { - string category = "None"; + string category = None; if (DateTime.Now - _plugin.LatestReleaseDate < TimeSpan.FromDays(7)) { - category = "RecentlyUpdated"; + category = RecentlyUpdated; } if (DateTime.Now - _plugin.DateAdded < TimeSpan.FromDays(7)) { - category = "NewRelease"; + category = NewRelease; } if (PluginManager.GetPluginForId(_plugin.ID) != null) { - category = "Installed"; + category = Installed; } return category; diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index fa63b9ba4..d9c61986e 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -1,16 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Media; using System.Windows.Media.Imaging; using Flow.Launcher.Core; @@ -24,8 +19,6 @@ using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; -using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames; -using Windows.Management.Deployment.Preview; namespace Flow.Launcher.ViewModel { @@ -296,10 +289,10 @@ namespace Flow.Launcher.ViewModel private IList LabelMaker(IList list) { return list.Select(p=>new PluginStoreItemViewModel(p)) - .OrderByDescending(p => p.Category == "NewRelease") - .ThenByDescending(p=>p.Category == "RecentlyUpdated") - .ThenByDescending(p => p.Category == "None") - .ThenByDescending(p => p.Category == "Installed") + .OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease) + .ThenByDescending(p=>p.Category == PluginStoreItemViewModel.RecentlyUpdated) + .ThenByDescending(p => p.Category == PluginStoreItemViewModel.None) + .ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed) .ToList(); }