add default token field and check token

This commit is contained in:
Kevin Zhang 2021-07-06 11:15:39 +08:00
parent e64771f707
commit 6f65e10a10
2 changed files with 7 additions and 6 deletions

View file

@ -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<Result> Results;
public Query Query;
public CancellationToken Token { get; init; }
public CancellationToken Token { get; init; } = default;
}
}
}

View file

@ -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");
}
;
}
};
}