move using to more specific place in Google.cs

This commit is contained in:
弘韬 张 2021-01-07 21:48:55 +08:00
parent 919d5d51ab
commit 1003ce4160

View file

@ -32,24 +32,24 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
return new List<string>();
}
using (resultStream)
if (resultStream.Length == 0) return new List<string>();
JsonDocument json;
try
{
if (resultStream.Length == 0) return new List<string>();
JsonDocument json;
try
{
using (resultStream)
json = await JsonDocument.ParseAsync(resultStream);
}
catch (JsonException e)
{
Log.Exception("|Google.Suggestions|can't parse suggestions", e);
return new List<string>();
}
var results = json?.RootElement.EnumerateArray().ElementAt(1);
return results?.EnumerateArray().Select(o => o.GetString()).ToList() ?? new List<string>();
}
catch (JsonException e)
{
Log.Exception("|Google.Suggestions|can't parse suggestions", e);
return new List<string>();
}
var results = json?.RootElement.EnumerateArray().ElementAt(1);
return results?.EnumerateArray().Select(o => o.GetString()).ToList() ?? new List<string>();
}
public override string ToString()