Add PluginsManager for managing PluginsManifest repo#231
Conversation
- do not allow InstallPlugin method to be called via API - move InstallPlugin functionality to PluginsManager for use exclusively
Plugins/Flow.Launcher.Plugin.PluginsManager/Models/PluginsManifest.cs
Outdated
Show resolved
Hide resolved
| return results | ||
| .Where(x => StringMatcher.FuzzySearch(searchName, x.Title).IsSearchPrecisionScoreMet()) | ||
| .Select(x => x) | ||
| .ToList(); |
There was a problem hiding this comment.
Why not use the score to order it?
Like
.Where(x=>{
x.Score = StringMatcher.FuzzySearch(searchName,x.Title));
return x.Score>0;
})There was a problem hiding this comment.
score > 0 will return a lot of results that have a score, that's why we are using IsSearchPrecisionScoreMet(), it matches the precision level that the user selected, default is 50, so only results with a score equal or higher will return.
There was a problem hiding this comment.
Well, you are not right here. The score property will make every raw score lower than search precision become 0, so no worry for more results. The one you suggested that can be lower than search precision is called rawScore.
There was a problem hiding this comment.
yeah you are right about the score property.
I dont see a benefit of doing x.score > 0 as oppose to just calling the function which has the logic embedded without having to hardcode any numbers
There was a problem hiding this comment.
I mean by changing x.score to the score from the fuzzy search can make the result list sort since the view model will sort it by its score.
There was a problem hiding this comment.
can you give me a code snippet please, not sure what you mean
There was a problem hiding this comment.
I mean by setting the score of each Result can help the result list to sort it based on the score.
Check out this
Flow.Launcher/Flow.Launcher/ViewModel/ResultsViewModel.cs
Lines 156 to 201 in 920668d
Although I don't believe this part of codes are clear enough, but it do provides the ability to sorts the results to display on the results list view based on their score.
There was a problem hiding this comment.
Ohh gotcha, I forgot to set the score for each of the result.
There was a problem hiding this comment.
sorted. good catch, thank you
| var results = new List<Result>(); | ||
|
|
||
| pluginsManifest | ||
| .UserPlugins | ||
| .ForEach(x => results.Add( | ||
| new Result | ||
| { | ||
| Title = $"{x.Name} by {x.Author}", | ||
| SubTitle = x.Description, | ||
| IcoPath = icoPath, | ||
| Action = e => | ||
| { | ||
| Application.Current.MainWindow.Hide(); | ||
| InstallOrUpdate(x); | ||
|
|
||
| return true; | ||
| } | ||
| })); | ||
|
|
||
| return Search(results, searchName); |
There was a problem hiding this comment.
Well I do think it will be more elegent to simply use the Select method to get the resultlist but this is fine, too.
| var unzippedFolderCount = Directory.GetDirectories(unzippedParentFolderPath).Length; | ||
| var unzippedFilesCount = Directory.GetFiles(unzippedParentFolderPath).Length; | ||
|
|
||
| // addjust path depending on how the plugin is zipped up |
| internal static void Download(string downloadUrl, string toFilePath) | ||
| { | ||
| using var wc = new WebClient { Proxy = Http.WebProxy() }; | ||
|
|
||
| wc.DownloadFile(downloadUrl, toFilePath); | ||
| } |
There was a problem hiding this comment.
Since we have referenced to Flow.Launcher.Infruastructure, why not simply use the one lies in Http.cs?
This PR adds the new plugin PluginsManager to manage installing, and uninstalling plugins.
New PR will be added for the update plugins feature & context menu