Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions Flow.Launcher.Plugin/Feature.cs

This file was deleted.

14 changes: 14 additions & 0 deletions Flow.Launcher.Plugin/Features.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Threading;

namespace Flow.Launcher.Plugin
{
/// <summary>
/// Base Interface for Flow's special plugin feature interface
/// </summary>
public interface IFeatures
{
}
}
4 changes: 2 additions & 2 deletions Flow.Launcher.Plugin/Interfaces/IAsyncReloadable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace Flow.Launcher.Plugin
/// The command that allows user to manual reload is exposed via Plugin.Sys, and
/// it will call the plugins that have implemented this interface.
/// </summary>
public interface IAsyncReloadable
public interface IAsyncReloadable : IFeatures
{
Task ReloadDataAsync();
}
}
}
9 changes: 9 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IContextMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Flow.Launcher.Plugin
{
public interface IContextMenu : IFeatures
{
List<Result> LoadContextMenus(Result selectedResult);
}
}
12 changes: 12 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Represent plugins that support internationalization
/// </summary>
public interface IPluginI18n : IFeatures
{
string GetTranslatedPluginTitle();

string GetTranslatedPluginDescription();
}
}
4 changes: 2 additions & 2 deletions Flow.Launcher.Plugin/Interfaces/IReloadable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
/// If requiring reloading data asynchronously, please use the IAsyncReloadable interface
/// </para>
/// </summary>
public interface IReloadable
public interface IReloadable : IFeatures
{
void ReloadData();
}
}
}
20 changes: 20 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IResultUpdated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Threading;

namespace Flow.Launcher.Plugin
{
public interface IResultUpdated : IFeatures
{
event ResultUpdatedEventHandler ResultsUpdated;
}

public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e);

public class ResultUpdatedEventArgs : EventArgs
{
public List<Result> Results;
public Query Query;
public CancellationToken Token { get; init; }
}
}
4 changes: 2 additions & 2 deletions Flow.Launcher.Plugin/Interfaces/ISavable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/// Otherwise if LoadSettingJsonStorage or SaveSettingJsonStorage has been callded,
/// plugin settings will be automatically saved (see Flow.Launcher/PublicAPIInstance.SavePluginSettings) by Flow
/// </summary>
public interface ISavable
public interface ISavable : IFeatures
{
void Save();
}
}
}
2 changes: 1 addition & 1 deletion Flow.Launcher.Plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

* Defines base objects and interfaces for plugins
* Plugin authors making C# plugins should reference this DLL via nuget
* Contains base commands used by all plugins
* Contains commands and models that can be used by plugins
21 changes: 12 additions & 9 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ private void RegisterResultsUpdatedEvent()
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)))
{
Log.Error("MainViewModel", "Unable to add item to Result Update Queue");
}
;
return;
}

var token = e.Token == default ? _updateToken : e.Token;

PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query);
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(e.Results, pair.Metadata, e.Query, token)))
{
Log.Error("MainViewModel", "Unable to add item to Result Update Queue");
}
};
}
Expand Down Expand Up @@ -460,7 +463,7 @@ private void QueryHistory()
}

private readonly IReadOnlyList<Result> _emptyResult = new List<Result>();

private async void QueryResults()
{
_updateSource?.Cancel();
Expand Down Expand Up @@ -554,7 +557,7 @@ async Task QueryTask(PluginPair plugin)
await Task.Yield();

IReadOnlyList<Result> results = await PluginManager.QueryForPluginAsync(plugin, query, currentCancellationToken);

currentCancellationToken.ThrowIfCancellationRequested();

results ??= _emptyResult;
Expand Down