diff --git a/Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs b/Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs index 0bea2e0e1..bb1279b2c 100644 --- a/Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs +++ b/Flow.Launcher.Core/ExternalPlugins/UserPlugin.cs @@ -17,9 +17,5 @@ namespace Flow.Launcher.Core.ExternalPlugins public DateTime LatestReleaseDate { get; set; } public DateTime DateAdded { get; set; } - /* Label Data for Plugin Store */ - public bool LabelNew { get; set; } - public bool LabelInstalled { get; set; } - public bool LabelUpdated { get; set; } } } diff --git a/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs b/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs new file mode 100644 index 000000000..94b435f1a --- /dev/null +++ b/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs @@ -0,0 +1,27 @@ +using System; +using Flow.Launcher.Core.ExternalPlugins; +using Flow.Launcher.Core.Plugin; +using Flow.Launcher.Plugin; + +namespace Flow.Launcher.ViewModel +{ + public class PluginStoreItemViewModel : BaseModel + { + public PluginStoreItemViewModel(UserPlugin plugin) + { + _plugin = plugin; + } + + private UserPlugin _plugin; + + public string Name => _plugin.Name; + public string Description => _plugin.Description; + public string Author => _plugin.Author; + public string Version => _plugin.Version; + + + public bool LabelNew => _plugin.LatestReleaseDate-DateTime.Now < TimeSpan.FromDays(7); + public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null; + public bool LabelUpdated => _plugin.DateAdded -DateTime.Now < TimeSpan.FromDays(7); + } +} diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index fd0f49c82..99a05548f 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -283,7 +283,7 @@ namespace Flow.Launcher.ViewModel } } - public IList ExternalPlugins + public IList ExternalPlugins { get { @@ -291,45 +291,13 @@ namespace Flow.Launcher.ViewModel } } - private IList LabelMaker(IList list) + private IList LabelMaker(IList list) { - foreach (UserPlugin item in list) - { - item.LabelNew = false; - item.LabelInstalled = false; - item.LabelUpdated = false; - - foreach (var vm in PluginViewModels) - { - - var id = vm.PluginPair.Metadata.ID; - if (item.ID == vm.PluginPair.Metadata.ID) // Add Installed Label - { - item.LabelInstalled = true; - } - - TimeSpan UpdatedDay = DateTime.Now.Subtract(item.LatestReleaseDate); - int LastUpdated = UpdatedDay.Days; - - if (LastUpdated <= 5) // Add Updated Label - { - item.LabelUpdated = true; - } - } - TimeSpan AddedDay = DateTime.Now.Subtract(item.DateAdded); - int DateAdded = AddedDay.Days; - if (DateAdded <= 7) - { - - item.LabelNew = true; // Add New Label - item.LabelUpdated = false; // Hide Updated Label when Added New Label. New and Update doesn't show both same time. - } - } - - // New first, Updated second. Installed to bottom of list. - list = list.OrderByDescending(x => x.LabelNew).OrderByDescending(x => x.LabelUpdated).ThenBy(y => y.LabelInstalled).ToList(); - - return list; + return list.Select(p=>new PluginStoreItemViewModel(p)) + .OrderBy(p=>p.LabelNew) + .ThenByDescending(p=>p.LabelUpdated) + .ThenBy(p=>p.LabelInstalled) + .ToList(); } public Control SettingProvider