Skip to content

Commit bad304b

Browse files
committed
Query themes every time
1 parent 468c0b2 commit bad304b

File tree

2 files changed

+5
-57
lines changed

2 files changed

+5
-57
lines changed

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Flow.Launcher.Infrastructure;
88
using Flow.Launcher.Infrastructure.Logger;
99
using Flow.Launcher.Infrastructure.UserSettings;
10-
using Flow.Launcher.Plugin.SharedCommands;
1110
using Windows.Win32;
1211
using Windows.Win32.Foundation;
1312
using Windows.Win32.Security;
@@ -17,7 +16,7 @@
1716

1817
namespace Flow.Launcher.Plugin.Sys
1918
{
20-
public class Main : IPlugin, ISettingProvider, IPluginI18n, IDisposable
19+
public class Main : IPlugin, ISettingProvider, IPluginI18n
2120
{
2221
private PluginInitContext context;
2322
private ThemeSelector themeSelector;
@@ -486,10 +485,5 @@ public string GetTranslatedPluginDescription()
486485
{
487486
return context.API.GetTranslation("flowlauncher_plugin_sys_plugin_description");
488487
}
489-
490-
public void Dispose()
491-
{
492-
themeSelector.Dispose();
493-
}
494488
}
495489
}
Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,26 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using CommunityToolkit.Mvvm.DependencyInjection;
54
using Flow.Launcher.Core.Resource;
65

76
namespace Flow.Launcher.Plugin.Sys
87
{
9-
public class ThemeSelector : IDisposable
8+
public class ThemeSelector
109
{
1110
public const string Keyword = "fltheme";
1211

1312
private readonly Theme _theme;
1413
private readonly PluginInitContext _context;
1514

16-
private IEnumerable<string> themes;
17-
1815
public ThemeSelector(PluginInitContext context)
1916
{
2017
_context = context;
2118
_theme = Ioc.Default.GetRequiredService<Theme>();
22-
context.API.VisibilityChanged += OnVisibilityChanged;
23-
}
24-
25-
~ThemeSelector()
26-
{
27-
Dispose(false);
2819
}
2920

3021
public List<Result> Query(Query query)
3122
{
32-
if (query.IsReQuery)
33-
{
34-
LoadThemes();
35-
}
23+
var themes = _theme.LoadAvailableThemes().Select(x => x.FileNameWithoutExtension);
3624

3725
string search = query.SecondToEndSearch;
3826

@@ -50,17 +38,6 @@ public List<Result> Query(Query query)
5038
.ToList();
5139
}
5240

53-
private void OnVisibilityChanged(object sender, VisibilityChangedEventArgs args)
54-
{
55-
if (args.IsVisible && !_context.CurrentPluginMetadata.Disabled)
56-
{
57-
LoadThemes();
58-
}
59-
}
60-
61-
private void LoadThemes()
62-
=> themes = _theme.LoadAvailableThemes().Select(x => x.FileNameWithoutExtension);
63-
6441
private Result CreateThemeResult(string theme) => CreateThemeResult(theme, 0, null);
6542

6643
private Result CreateThemeResult(string theme, int score, IList<int> highlightData)
@@ -69,6 +46,7 @@ private Result CreateThemeResult(string theme, int score, IList<int> highlightDa
6946
if (theme == _theme.CurrentTheme)
7047
{
7148
title = $"{theme} ★";
49+
// Set current theme to the top
7250
score = 2000;
7351
}
7452
else
@@ -92,29 +70,5 @@ private Result CreateThemeResult(string theme, int score, IList<int> highlightDa
9270
}
9371
};
9472
}
95-
96-
private bool disposed;
97-
protected virtual void Dispose(bool disposing)
98-
{
99-
if (!disposed)
100-
{
101-
if (disposing)
102-
{
103-
// Dispose managed resources
104-
if (_context?.API != null)
105-
{
106-
_context.API.VisibilityChanged -= OnVisibilityChanged;
107-
}
108-
}
109-
// Free unmanaged resources
110-
disposed = true;
111-
}
112-
}
113-
114-
public void Dispose()
115-
{
116-
Dispose(true);
117-
GC.SuppressFinalize(this);
118-
}
11973
}
12074
}

0 commit comments

Comments
 (0)