Skip to content

Commit 8dd24de

Browse files
committed
update category strings to constants
1 parent ad3fd4a commit 8dd24de

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

Flow.Launcher/Converters/TextConverter.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Globalization;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
using System.Windows;
8-
using System.Windows.Controls;
93
using System.Windows.Data;
104
using Flow.Launcher.Core.Resource;
5+
using Flow.Launcher.ViewModel;
116

127
namespace Flow.Launcher.Converters
138
{
@@ -18,23 +13,17 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1813
var ID = value.ToString();
1914
switch(ID)
2015
{
21-
case "NewRelease":
16+
case PluginStoreItemViewModel.NewRelease:
2217
return InternationalizationManager.Instance.GetTranslation("pluginStore_NewRelease");
23-
break;
24-
case "RecentlyUpdated":
18+
case PluginStoreItemViewModel.RecentlyUpdated:
2519
return InternationalizationManager.Instance.GetTranslation("pluginStore_RecentlyUpdated");
26-
break;
27-
case "None":
20+
case PluginStoreItemViewModel.None:
2821
return InternationalizationManager.Instance.GetTranslation("pluginStore_None");
29-
break;
30-
case "installed":
22+
case PluginStoreItemViewModel.Installed:
3123
return InternationalizationManager.Instance.GetTranslation("pluginStore_Installed");
32-
break;
3324
default:
3425
return ID;
35-
break;
3626
}
37-
3827

3928
}
4029

Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Diagnostics;
32
using Flow.Launcher.Core.ExternalPlugins;
43
using Flow.Launcher.Core.Plugin;
54
using Flow.Launcher.Plugin;
@@ -27,23 +26,29 @@ public PluginStoreItemViewModel(UserPlugin plugin)
2726
public string IcoPath => _plugin.IcoPath;
2827

2928
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
30-
public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
29+
public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
30+
31+
internal const string None = "None";
32+
internal const string RecentlyUpdated = "RecentlyUpdated";
33+
internal const string NewRelease = "NewRelease";
34+
internal const string Installed = "Installed";
35+
3136
public string Category
3237
{
3338
get
3439
{
35-
string category = "None";
40+
string category = None;
3641
if (DateTime.Now - _plugin.LatestReleaseDate < TimeSpan.FromDays(7))
3742
{
38-
category = "RecentlyUpdated";
43+
category = RecentlyUpdated;
3944
}
4045
if (DateTime.Now - _plugin.DateAdded < TimeSpan.FromDays(7))
4146
{
42-
category = "NewRelease";
47+
category = NewRelease;
4348
}
4449
if (PluginManager.GetPluginForId(_plugin.ID) != null)
4550
{
46-
category = "Installed";
51+
category = Installed;
4752
}
4853

4954
return category;

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
4-
using System.Diagnostics;
5-
using System.Globalization;
63
using System.IO;
74
using System.Linq;
85
using System.Net;
96
using System.Threading.Tasks;
107
using System.Windows;
118
using System.Windows.Controls;
12-
using System.Windows.Data;
13-
using System.Windows.Documents;
149
using System.Windows.Media;
1510
using System.Windows.Media.Imaging;
1611
using Flow.Launcher.Core;
@@ -24,8 +19,6 @@
2419
using Flow.Launcher.Infrastructure.UserSettings;
2520
using Flow.Launcher.Plugin;
2621
using Flow.Launcher.Plugin.SharedModels;
27-
using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames;
28-
using Windows.Management.Deployment.Preview;
2922

3023
namespace Flow.Launcher.ViewModel
3124
{
@@ -296,10 +289,10 @@ public IList<PluginStoreItemViewModel> ExternalPlugins
296289
private IList<PluginStoreItemViewModel> LabelMaker(IList<UserPlugin> list)
297290
{
298291
return list.Select(p=>new PluginStoreItemViewModel(p))
299-
.OrderByDescending(p => p.Category == "NewRelease")
300-
.ThenByDescending(p=>p.Category == "RecentlyUpdated")
301-
.ThenByDescending(p => p.Category == "None")
302-
.ThenByDescending(p => p.Category == "Installed")
292+
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
293+
.ThenByDescending(p=>p.Category == PluginStoreItemViewModel.RecentlyUpdated)
294+
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)
295+
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed)
303296
.ToList();
304297
}
305298

0 commit comments

Comments
 (0)