Skip to content

Commit 7dc66ea

Browse files
committed
Merge dev
2 parents 8ec781d + a47f8b3 commit 7dc66ea

File tree

11 files changed

+238
-156
lines changed

11 files changed

+238
-156
lines changed

Flow.Launcher.Infrastructure/Constant.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ public static class Constant
3535
public const string DefaultTheme = "Darker";
3636

3737
public const string Themes = "Themes";
38+
39+
public const string Website = "https://flow-launcher.github.io";
3840
}
3941
}

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ public static async Task<string> Get([NotNull] string url, string encoding = "UT
111111
}
112112
}
113113
}
114-
}
114+
}

Flow.Launcher/SettingWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@
429429
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding ActivatedTimes, Mode=OneWay}" FontSize="12" />
430430
<TextBlock Grid.Row="1" Grid.Column="0" Text="{DynamicResource website}"/>
431431
<TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left">
432-
<Hyperlink NavigateUri="{Binding Github, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
433-
<Run Text="{Binding Github, Mode=OneWay}" />
432+
<Hyperlink NavigateUri="{Binding Website, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
433+
<Run Text="{Binding Website, Mode=OneWay}" />
434434
</Hyperlink>
435435
</TextBlock>
436436
<TextBlock Grid.Row="2" Grid.Column="0" Text="Version" />

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public string TestProxy()
213213

214214
#region plugin
215215

216-
public static string Plugin => "http://www.wox.one/plugin";
216+
public static string Plugin => @"https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest";
217217
public PluginViewModel SelectedPlugin { get; set; }
218218

219219
public IList<PluginViewModel> PluginViewModels
@@ -450,7 +450,7 @@ public FamilyTypeface SelectedResultFontFaces
450450

451451
#region about
452452

453-
public string Github => _updater.GitHubRepository;
453+
public string Website => Constant.Website;
454454
public string ReleaseNotes => _updater.GitHubRepository + @"/releases/latest";
455455
public static string Version => Constant.Version;
456456
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);

Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ internal class ContextMenu : IContextMenu
1010
{
1111
private PluginInitContext Context { get; set; }
1212

13-
private Settings Settings { get; set; }
14-
15-
public ContextMenu(PluginInitContext context, Settings settings)
13+
public ContextMenu(PluginInitContext context)
1614
{
1715
Context = context;
18-
Settings = settings;
1916
}
2017

2118
public List<Result> LoadContextMenus(Result selectedResult)
@@ -58,7 +55,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
5855
? pluginManifestInfo.UrlSourceCode.Replace("/tree/master", "/issues/new/choose")
5956
: pluginManifestInfo.UrlSourceCode;
6057

61-
SharedCommands.SearchWeb.NewBrowserWindow(link);
58+
SharedCommands.SearchWeb.NewTabInBrowser(link);
6259
return true;
6360
}
6461
},
@@ -69,7 +66,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
6966
IcoPath = selectedResult.IcoPath,
7067
Action = _ =>
7168
{
72-
SharedCommands.SearchWeb.NewBrowserWindow("https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest");
69+
SharedCommands.SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest");
7370
return true;
7471
}
7572
}

Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using Flow.Launcher.Infrastructure.Storage;
2-
using Flow.Launcher.Infrastructure.UserSettings;
32
using Flow.Launcher.Plugin.PluginsManager.ViewModels;
43
using Flow.Launcher.Plugin.PluginsManager.Views;
54
using System.Collections.Generic;
5+
using System.Linq;
66
using System.Windows.Controls;
7+
using Flow.Launcher.Infrastructure;
8+
using System;
9+
using System.Threading.Tasks;
710

811
namespace Flow.Launcher.Plugin.PluginsManager
912
{
@@ -17,6 +20,10 @@ public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu, IPluginI1
1720

1821
private IContextMenu contextMenu;
1922

23+
internal PluginsManager pluginManager;
24+
25+
private DateTime lastUpdateTime;
26+
2027
public Control CreateSettingPanel()
2128
{
2229
return new PluginsManagerSettings(viewModel);
@@ -27,7 +34,9 @@ public void Init(PluginInitContext context)
2734
Context = context;
2835
viewModel = new SettingsViewModel(context);
2936
Settings = viewModel.Settings;
30-
contextMenu = new ContextMenu(Context, Settings);
37+
contextMenu = new ContextMenu(Context);
38+
pluginManager = new PluginsManager(Context, Settings);
39+
lastUpdateTime = DateTime.Now;
3140
}
3241

3342
public List<Result> LoadContextMenus(Result selectedResult)
@@ -39,17 +48,29 @@ public List<Result> Query(Query query)
3948
{
4049
var search = query.Search.ToLower();
4150

42-
var pluginManager = new PluginsManager(Context, Settings);
43-
44-
if (!string.IsNullOrEmpty(search)
45-
&& ($"{Settings.HotkeyUninstall} ".StartsWith(search) || search.StartsWith($"{Settings.HotkeyUninstall} ")))
46-
return pluginManager.RequestUninstall(search);
51+
if (string.IsNullOrWhiteSpace(search))
52+
return pluginManager.GetDefaultHotKeys();
4753

48-
if (!string.IsNullOrEmpty(search)
49-
&& ($"{Settings.HotkeyUpdate} ".StartsWith(search) || search.StartsWith($"{Settings.HotkeyUpdate} ")))
50-
return pluginManager.RequestUpdate(search);
54+
if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours
55+
{
56+
Task.Run(async () =>
57+
{
58+
await pluginManager.UpdateManifest();
59+
lastUpdateTime = DateTime.Now;
60+
});
61+
}
5162

52-
return pluginManager.RequestInstallOrUpdate(search);
63+
return search switch
64+
{
65+
var s when s.StartsWith(Settings.HotKeyInstall) => pluginManager.RequestInstallOrUpdate(s),
66+
var s when s.StartsWith(Settings.HotkeyUninstall) => pluginManager.RequestUninstall(s),
67+
var s when s.StartsWith(Settings.HotkeyUpdate) => pluginManager.RequestUpdate(s),
68+
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
69+
{
70+
hotkey.Score = StringMatcher.FuzzySearch(search, hotkey.Title).Score;
71+
return hotkey.Score > 0;
72+
}).ToList()
73+
};
5374
}
5475

5576
public void Save()

Plugins/Flow.Launcher.Plugin.PluginsManager/Models/PluginsManifest.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Flow.Launcher.Infrastructure.Http;
22
using Flow.Launcher.Infrastructure.Logger;
3-
using Newtonsoft.Json;
43
using System;
54
using System.Collections.Generic;
5+
using System.Text.Json;
66
using System.Threading.Tasks;
77

88
namespace Flow.Launcher.Plugin.PluginsManager.Models
@@ -13,18 +13,17 @@ internal class PluginsManifest
1313

1414
internal PluginsManifest()
1515
{
16-
DownloadManifest().Wait();
16+
Task.Run(async () => await DownloadManifest()).Wait();
1717
}
1818

19-
private async Task DownloadManifest()
19+
internal async Task DownloadManifest()
2020
{
21-
var json = string.Empty;
2221
try
2322
{
24-
json = await Http.Get(
25-
"https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json");
23+
await using var jsonStream = await Http.GetStreamAsync("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/main/plugins.json")
24+
.ConfigureAwait(false);
2625

27-
UserPlugins = JsonConvert.DeserializeObject<List<UserPlugin>>(json);
26+
UserPlugins = await JsonSerializer.DeserializeAsync<List<UserPlugin>>(jsonStream).ConfigureAwait(false);
2827
}
2928
catch (Exception e)
3029
{

0 commit comments

Comments
 (0)