Skip to content

Commit cd1d096

Browse files
committed
Improvement
1 parent 2609d85 commit cd1d096

File tree

2 files changed

+17
-46
lines changed

2 files changed

+17
-46
lines changed

Main.cs

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,66 +18,35 @@ public class AppUpgrader : IAsyncPlugin
1818
public Task InitAsync(PluginInitContext context)
1919
{
2020
Context = context;
21-
try
22-
{
23-
upgradableApps = GetUpgradableAppsAsync().GetAwaiter().GetResult();
24-
}
25-
catch (Exception ex) { }
2621
return Task.CompletedTask;
2722
}
2823

2924
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
3025
{
31-
await Task.Yield();
32-
3326
var results = new List<Result>();
34-
string keyword = query.FirstSearch.Trim().ToLower();
35-
36-
if (upgradableApps == null)
27+
try
3728
{
38-
return new List<Result>
39-
{
40-
new Result
41-
{
42-
Title = "Update Check Error",
43-
SubTitle = "Unable to check for available updates",
44-
IcoPath = "Images\\app.png"
45-
}
46-
};
29+
upgradableApps = GetUpgradableAppsAsync().GetAwaiter().GetResult();
4730
}
48-
49-
if (!upgradableApps.Any())
31+
catch (Exception ex)
5032
{
51-
return new List<Result>
52-
{
53-
new Result
54-
{
55-
Title = "No Updates Available",
56-
SubTitle = "All your applications are up to date",
57-
IcoPath = "Images\\app.png",
58-
Action = context =>
59-
{
60-
try
61-
{
62-
Task.Run(async () =>
63-
{
64-
upgradableApps = await GetUpgradableAppsAsync();
65-
}, token);
66-
return true;
67-
}
68-
catch (Exception ex) { return false;}
33+
return results;
34+
}
6935

70-
}
71-
}
72-
};
36+
await Task.Yield();
37+
string keyword = query.FirstSearch.Trim().ToLower();
38+
39+
if (upgradableApps == null || !upgradableApps.Any())
40+
{
41+
return results;
7342
}
7443

7544
foreach (var app in upgradableApps.ToList())
7645
{
7746
results.Add(new Result
7847
{
79-
Title = $"Update {app.Name}",
80-
SubTitle = $"Version {app.Version} {app.AvailableVersion}",
48+
Title = $"Upgrade {app.Name}",
49+
SubTitle = $"From {app.Version} to {app.AvailableVersion}",
8150
Action = context =>
8251
{
8352
Task.Run(async () =>
@@ -86,7 +55,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
8655
{
8756
await PerformUpgradeAsync(app);
8857
}
89-
catch (Exception ex) { }
58+
catch (Exception ex){}
9059
}, token);
9160
return true;
9261
},
@@ -97,6 +66,8 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
9766
return results;
9867
}
9968

69+
70+
10071
private async Task PerformUpgradeAsync(UpgradableApp app)
10172
{
10273
Context.API.ShowMsg($"Attempting to update {app.Name}...");

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.6",
7+
"Version": "1.0.7",
88
"Language": "csharp",
99
"Website": "https://github.com/Exarilo/Flow.Launcher.Plugin.AppUpgrader",
1010
"IcoPath": "Images\\app.png",

0 commit comments

Comments
 (0)