From d8f32806324872b8977aab5cdc05230b82ee4bb0 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 10 Feb 2025 11:54:09 +0800 Subject: [PATCH] Fix unneccessary plugin result update --- Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs | 10 +++++++--- .../ViewModels/SettingsPanePluginStoreViewModel.cs | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs index 233612f50..54080e150 100644 --- a/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs +++ b/Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs @@ -27,12 +27,16 @@ namespace Flow.Launcher.Core.ExternalPlugins { await manifestUpdateLock.WaitAsync(token).ConfigureAwait(false); - if (UserPlugins == null || UserPlugins.Count == 0 || usePrimaryUrlOnly || DateTime.Now.Subtract(lastFetchedAt) >= fetchTimeout) + if (UserPlugins == null || usePrimaryUrlOnly || DateTime.Now.Subtract(lastFetchedAt) >= fetchTimeout) { var results = await mainPluginStore.FetchAsync(token, usePrimaryUrlOnly).ConfigureAwait(false); - UserPlugins = results; - lastFetchedAt = DateTime.Now; + // If the results are empty, we shouldn't update the manifest because the results are invalid. + if (results.Count != 0) + { + UserPlugins = results; + lastFetchedAt = DateTime.Now; + } } } catch (Exception e) diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginStoreViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginStoreViewModel.cs index e06931011..a6cc3c535 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginStoreViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPanePluginStoreViewModel.cs @@ -13,8 +13,8 @@ public partial class SettingsPanePluginStoreViewModel : BaseModel { public string FilterText { get; set; } = string.Empty; - public IList ExternalPlugins => PluginsManifest.UserPlugins - .Select(p => new PluginStoreItemViewModel(p)) + public IList ExternalPlugins => + PluginsManifest.UserPlugins?.Select(p => new PluginStoreItemViewModel(p)) .OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease) .ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated) .ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)