mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #563 from taooceros/IFeatureExpand
Move IAsyncReloadable.cs, IReloadable.cs, ISavable.cs to IFeatures
This commit is contained in:
commit
d623e3da3e
14 changed files with 74 additions and 52 deletions
|
|
@ -1,36 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Flow.Launcher.Plugin
|
||||
{
|
||||
public interface IFeatures { }
|
||||
|
||||
public interface IContextMenu : IFeatures
|
||||
{
|
||||
List<Result> LoadContextMenus(Result selectedResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represent plugins that support internationalization
|
||||
/// </summary>
|
||||
public interface IPluginI18n : IFeatures
|
||||
{
|
||||
string GetTranslatedPluginTitle();
|
||||
|
||||
string GetTranslatedPluginDescription();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
14
Flow.Launcher.Plugin/Features.cs
Normal file
14
Flow.Launcher.Plugin/Features.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -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
Flow.Launcher.Plugin/Interfaces/IContextMenu.cs
Normal file
9
Flow.Launcher.Plugin/Interfaces/IContextMenu.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Flow.Launcher.Plugin
|
||||
{
|
||||
public interface IContextMenu : IFeatures
|
||||
{
|
||||
List<Result> LoadContextMenus(Result selectedResult);
|
||||
}
|
||||
}
|
||||
12
Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs
Normal file
12
Flow.Launcher.Plugin/Interfaces/IPluginI18n.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
namespace Flow.Launcher.Plugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Represent plugins that support internationalization
|
||||
/// </summary>
|
||||
public interface IPluginI18n : IFeatures
|
||||
{
|
||||
string GetTranslatedPluginTitle();
|
||||
|
||||
string GetTranslatedPluginDescription();
|
||||
}
|
||||
}
|
||||
|
|
@ -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
Flow.Launcher.Plugin/Interfaces/IResultUpdated.cs
Normal file
20
Flow.Launcher.Plugin/Interfaces/IResultUpdated.cs
Normal file
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -135,14 +135,17 @@ 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)))
|
||||
{
|
||||
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");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -460,7 +463,7 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
|
||||
private readonly IReadOnlyList<Result> _emptyResult = new List<Result>();
|
||||
|
||||
|
||||
private async void QueryResults()
|
||||
{
|
||||
_updateSource?.Cancel();
|
||||
|
|
@ -554,7 +557,7 @@ namespace Flow.Launcher.ViewModel
|
|||
await Task.Yield();
|
||||
|
||||
IReadOnlyList<Result> results = await PluginManager.QueryForPluginAsync(plugin, query, currentCancellationToken);
|
||||
|
||||
|
||||
currentCancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
results ??= _emptyResult;
|
||||
|
|
|
|||
Loading…
Reference in a new issue