mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use singleton in QuickFolderAccess.cs
This commit is contained in:
parent
9914124d20
commit
8a56cc6cd8
2 changed files with 20 additions and 13 deletions
|
|
@ -6,25 +6,31 @@ namespace Flow.Launcher.Plugin.Explorer.Search.FolderLinks
|
|||
{
|
||||
public class QuickFolderAccess
|
||||
{
|
||||
internal List<Result> FolderListMatched(Query query, List<FolderLink> folderLinks, PluginInitContext context)
|
||||
private readonly ResultManager _resultManager;
|
||||
|
||||
public QuickFolderAccess(PluginInitContext context)
|
||||
{
|
||||
_resultManager = new ResultManager(context);
|
||||
}
|
||||
|
||||
internal List<Result> FolderListMatched(Query query, List<FolderLink> folderLinks)
|
||||
{
|
||||
if (string.IsNullOrEmpty(query.Search))
|
||||
return new List<Result>();
|
||||
|
||||
string search = query.Search.ToLower();
|
||||
|
||||
var queriedFolderLinks = folderLinks.Where(x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
var queriedFolderLinks =
|
||||
folderLinks.Where(x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
return queriedFolderLinks.Select(item =>
|
||||
new ResultManager(context)
|
||||
.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
|
||||
.ToList();
|
||||
_resultManager.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
internal List<Result> FolderListAll(Query query, List<FolderLink> folderLinks, PluginInitContext context)
|
||||
internal List<Result> FolderListAll(Query query, List<FolderLink> folderLinks)
|
||||
=> folderLinks
|
||||
.Select(item =>
|
||||
new ResultManager(context).CreateFolderResult(item.Nickname, item.Path, item.Path, query))
|
||||
.Select(item => _resultManager.CreateFolderResult(item.Nickname, item.Path, item.Path, query))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
private readonly IndexSearch indexSearch;
|
||||
|
||||
private readonly QuickFolderAccess quickFolderAccess = new QuickFolderAccess();
|
||||
private readonly QuickFolderAccess quickFolderAccess;
|
||||
|
||||
private readonly ResultManager resultManager;
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
indexSearch = new IndexSearch(context);
|
||||
resultManager = new ResultManager(context);
|
||||
this.settings = settings;
|
||||
quickFolderAccess = new QuickFolderAccess(context);
|
||||
}
|
||||
|
||||
internal async Task<List<Result>> SearchAsync(Query query, CancellationToken token)
|
||||
|
|
@ -41,9 +42,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
|
||||
// This allows the user to type the assigned action keyword and only see the list of quick folder links
|
||||
if (string.IsNullOrEmpty(query.Search))
|
||||
return quickFolderAccess.FolderListAll(query, settings.QuickFolderAccessLinks, context);
|
||||
return quickFolderAccess.FolderListAll(query, settings.QuickFolderAccessLinks);
|
||||
|
||||
var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks, context);
|
||||
var quickFolderLinks = quickFolderAccess.FolderListMatched(query, settings.QuickFolderAccessLinks);
|
||||
|
||||
if (quickFolderLinks.Count > 0)
|
||||
results.AddRange(quickFolderLinks);
|
||||
|
|
|
|||
Loading…
Reference in a new issue