diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index 340d882dac4..ac23534b167 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -88,21 +88,24 @@ public async Task InitAsync(PluginInitContext context) bool cacheEmpty = !_win32s.Any() && !_uwps.Any(); - var a = Task.Run(() => + if (cacheEmpty || _settings.LastIndexTime.AddHours(30) < DateTime.Now) { - Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Win32Program index cost", IndexWin32Programs); - }); - - var b = Task.Run(() => + _ = Task.Run(async () => + { + await IndexProgramsAsync().ConfigureAwait(false); + WatchProgramUpdate(); + }); + } + else { - Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost", IndexUwpPrograms); - }); - - if (cacheEmpty) - await Task.WhenAll(a, b); + WatchProgramUpdate(); + } - Win32.WatchProgramUpdate(_settings); - _ = UWP.WatchPackageChange(); + static void WatchProgramUpdate() + { + Win32.WatchProgramUpdate(_settings); + _ = UWP.WatchPackageChange(); + } } public static void IndexWin32Programs() @@ -110,6 +113,8 @@ public static void IndexWin32Programs() var win32S = Win32.All(_settings); _win32s = win32S; ResetCache(); + _win32Storage.Save(_win32s); + _settings.LastIndexTime = DateTime.Now; } public static void IndexUwpPrograms() @@ -117,6 +122,8 @@ public static void IndexUwpPrograms() var applications = UWP.All(_settings); _uwps = applications; ResetCache(); + _uwpStorage.Save(_uwps); + _settings.LastIndexTime = DateTime.Now; } public static async Task IndexProgramsAsync() @@ -131,7 +138,6 @@ public static async Task IndexProgramsAsync() Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPProgram index cost", IndexUwpPrograms); }); await Task.WhenAll(a, b).ConfigureAwait(false); - _settings.LastIndexTime = DateTime.Today; } internal static void ResetCache() @@ -199,7 +205,6 @@ private static void DisableProgram(IProgram programToDelete) _ = Task.Run(() => { IndexUwpPrograms(); - _settings.LastIndexTime = DateTime.Today; }); } else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)) @@ -210,7 +215,6 @@ private static void DisableProgram(IProgram programToDelete) _ = Task.Run(() => { IndexWin32Programs(); - _settings.LastIndexTime = DateTime.Today; }); } } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index f59facaa4ac..ca203f803a7 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -121,13 +121,6 @@ private void RemoveRedundantSuffixes() public bool EnablePathSource { get; set; } = false; public bool EnableUWP { get; set; } = true; - public string CustomizedExplorer { get; set; } = Explorer; - public string CustomizedArgs { get; set; } = ExplorerArgs; - internal const char SuffixSeparator = ';'; - - internal const string Explorer = "explorer"; - - internal const string ExplorerArgs = "%s"; } } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 4b63d38a586..156f33ebc5f 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -87,18 +87,6 @@ public bool EnableUWP } } - public string CustomizedExplorerPath - { - get => _settings.CustomizedExplorer; - set => _settings.CustomizedExplorer = value; - } - - public string CustomizedExplorerArg - { - get => _settings.CustomizedArgs; - set => _settings.CustomizedArgs = value; - } - public bool ShowUWPCheckbox => UWP.SupportUWP(); public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)