Skip to content

Commit b8a3ad8

Browse files
committed
change foreach to select
1 parent 49b657b commit b8a3ad8

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,24 @@ internal List<Result> Search(List<Result> results, string searchName)
9090

9191
internal List<Result> RequestInstallOrUpdate(string searchName)
9292
{
93-
var results = new List<Result>();
94-
95-
pluginsManifest
93+
var results =
94+
pluginsManifest
9695
.UserPlugins
97-
.ForEach(x => results.Add(
98-
new Result
96+
.Select(x =>
97+
new Result
98+
{
99+
Title = $"{x.Name} by {x.Author}",
100+
SubTitle = x.Description,
101+
IcoPath = icoPath,
102+
Action = e =>
99103
{
100-
Title = $"{x.Name} by {x.Author}",
101-
SubTitle = x.Description,
102-
IcoPath = icoPath,
103-
Action = e =>
104-
{
105-
Application.Current.MainWindow.Hide();
106-
InstallOrUpdate(x);
107-
108-
return true;
109-
}
110-
}));
104+
Application.Current.MainWindow.Hide();
105+
InstallOrUpdate(x);
106+
107+
return true;
108+
}
109+
})
110+
.ToList();
111111

112112
return Search(results, searchName);
113113
}
@@ -156,23 +156,23 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
156156

157157
internal List<Result> RequestUninstall(string search)
158158
{
159-
var results = new List<Result>();
160-
161-
Context.API.GetAllPlugins()
162-
.ForEach(x => results.Add(
163-
new Result
164-
{
165-
Title = $"{x.Metadata.Name} by {x.Metadata.Author}",
166-
SubTitle = x.Metadata.Description,
167-
IcoPath = x.Metadata.IcoPath,
168-
Action = e =>
169-
{
170-
Application.Current.MainWindow.Hide();
171-
Uninstall(x.Metadata);
172-
173-
return true;
174-
}
175-
}));
159+
var results= Context.API
160+
.GetAllPlugins()
161+
.Select(x =>
162+
new Result
163+
{
164+
Title = $"{x.Metadata.Name} by {x.Metadata.Author}",
165+
SubTitle = x.Metadata.Description,
166+
IcoPath = x.Metadata.IcoPath,
167+
Action = e =>
168+
{
169+
Application.Current.MainWindow.Hide();
170+
Uninstall(x.Metadata);
171+
172+
return true;
173+
}
174+
})
175+
.ToList();
176176

177177
return Search(results, search);
178178
}

0 commit comments

Comments
 (0)