Skip to content

Commit d190029

Browse files
committed
Code improvment
1 parent d59c465 commit d190029

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Main.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,28 @@ public class AppUpgrader : IAsyncPlugin
1515
internal PluginInitContext Context;
1616
private List<UpgradableApp> upgradableApps;
1717

18-
public async Task InitAsync(PluginInitContext context)
18+
public Task InitAsync(PluginInitContext context)
1919
{
2020
Context = context;
21-
upgradableApps = await GetUpgradableAppsAsync();
21+
try
22+
{
23+
upgradableApps = GetUpgradableAppsAsync().GetAwaiter().GetResult();
24+
}
25+
catch (Exception ex) { }
26+
return Task.CompletedTask;
2227
}
2328

2429
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
2530
{
31+
if (upgradableApps == null || !upgradableApps.Any())
32+
{
33+
return new List<Result>();
34+
}
35+
2636
var results = new List<Result>();
2737
string keyword = query.FirstSearch.Trim().ToLower();
2838

39+
2940
foreach (var app in upgradableApps.ToList())
3041
{
3142
results.Add(new Result
@@ -34,7 +45,14 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
3445
SubTitle = $"From {app.Version} to {app.AvailableVersion}",
3546
Action = context =>
3647
{
37-
PerformUpgradeAsync(app);
48+
Task.Run(async () =>
49+
{
50+
try
51+
{
52+
await PerformUpgradeAsync(app);
53+
}
54+
catch (Exception ex){}
55+
}, token);
3856
return true;
3957
},
4058
IcoPath = "Images\\app.png"

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "AppUpgrader",
55
"Description": "Allows you to keep your applications up using winget",
66
"Author": "Exarilo",
7-
"Version": "1.0.3",
7+
"Version": "1.0.4",
88
"Language": "csharp",
99
"Website": "https://github.com/Exarilo/Flow.Launcher.Plugin.AppUpgrader",
1010
"IcoPath": "Images\\app.png",

0 commit comments

Comments
 (0)