From 6f65e10a106584f860f083c7f65b3660224393e2 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 6 Jul 2021 11:15:39 +0800 Subject: [PATCH] add default token field and check token --- Flow.Launcher.Plugin/Interfaces/Feature.cs | 8 +++++--- Flow.Launcher/ViewModel/MainViewModel.cs | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Plugin/Interfaces/Feature.cs b/Flow.Launcher.Plugin/Interfaces/Feature.cs index d3b07f38b..eaffea28e 100644 --- a/Flow.Launcher.Plugin/Interfaces/Feature.cs +++ b/Flow.Launcher.Plugin/Interfaces/Feature.cs @@ -5,7 +5,9 @@ using System.Threading; namespace Flow.Launcher.Plugin { - public interface IFeatures { } + public interface IFeatures + { + } public interface IContextMenu : IFeatures { @@ -33,6 +35,6 @@ namespace Flow.Launcher.Plugin { public List Results; public Query Query; - public CancellationToken Token { get; init; } + public CancellationToken Token { get; init; } = default; } -} +} \ No newline at end of file diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 1bdf6af1e..b0bd49657 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -135,14 +135,13 @@ namespace Flow.Launcher.ViewModel var plugin = (IResultUpdated)pair.Plugin; plugin.ResultsUpdated += (s, e) => { - if (e.Query.RawQuery == QueryText) // TODO: allow cancellation + if (e.Query.RawQuery == QueryText && !e.Token.IsCancellationRequested) { PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); - if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, _updateToken))) + if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, e.Token))) { Log.Error("MainViewModel", "Unable to add item to Result Update Queue"); } - ; } }; }