mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #346 from taooceros/fixSuggestSource
Remove unused check for Stream length
This commit is contained in:
commit
dec9941cce
5 changed files with 8 additions and 14 deletions
|
|
@ -195,11 +195,11 @@ namespace Flow.Launcher.Core.Plugin
|
|||
catch (OperationCanceledException)
|
||||
{
|
||||
// null will be fine since the results will only be added into queue if the token hasn't been cancelled
|
||||
return results = null;
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception($"|PluginManager.QueryForPlugin|Exception for plugin <{pair.Metadata.Name}> when query <{query}>", e);
|
||||
Log.Exception($"|PluginManager.QueryForPlugin|Exception for plugin <{pair.Metadata.Name}> when query <{query}>", e);
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ namespace Flow.Launcher.Plugin.WebSearch
|
|||
var source = _settings.SelectedSuggestion;
|
||||
if (source != null)
|
||||
{
|
||||
var suggestions = await source.Suggestions(keyword, token);
|
||||
var suggestions = await source.Suggestions(keyword, token).ConfigureAwait(false);
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
return null;
|
||||
|
||||
var resultsFromSuggestion = suggestions.Select(o => new Result
|
||||
var resultsFromSuggestion = suggestions?.Select(o => new Result
|
||||
{
|
||||
Title = o,
|
||||
SubTitle = subtitle,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
catch (HttpRequestException e)
|
||||
{
|
||||
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
|
||||
return new List<string>();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(result)) return new List<string>();
|
||||
|
|
|
|||
|
|
@ -24,16 +24,13 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
const string api = "https://api.bing.com/qsonhs.aspx?q=";
|
||||
|
||||
using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query), token).ConfigureAwait(false);
|
||||
|
||||
if (resultStream.Length == 0)
|
||||
return new List<string>(); // this handles the cancellation
|
||||
|
||||
|
||||
json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token)).RootElement.GetProperty("AS");
|
||||
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
return null;
|
||||
return new List<string>();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,15 +24,12 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
|
||||
using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);
|
||||
|
||||
if (resultStream.Length == 0)
|
||||
return new List<string>();
|
||||
|
||||
json = await JsonDocument.ParseAsync(resultStream);
|
||||
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
return null;
|
||||
return new List<string>();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue