@@ -20,7 +20,7 @@ public class Main : ISettingProvider, IPlugin, IAsyncReloadable, IPluginI18n, IC
20
20
{
21
21
internal static PluginInitContext Context { get ; set ; } = null ! ;
22
22
private static Settings _settings = null ! ;
23
-
23
+
24
24
private BookmarkLoaderService _bookmarkLoader = null ! ;
25
25
private FaviconService _faviconService = null ! ;
26
26
private BookmarkWatcherService _bookmarkWatcher = null ! ;
@@ -38,7 +38,7 @@ public void Init(PluginInitContext context)
38
38
_settings . CustomBrowsers . CollectionChanged += OnCustomBrowsersChanged ;
39
39
40
40
var tempPath = SetupTempDirectory ( ) ;
41
-
41
+
42
42
_bookmarkLoader = new BookmarkLoaderService ( Context , _settings , tempPath ) ;
43
43
_faviconService = new FaviconService ( Context , _settings , tempPath ) ;
44
44
_bookmarkWatcher = new BookmarkWatcherService ( ) ;
@@ -78,7 +78,7 @@ public List<Result> Query(Query query)
78
78
. Select ( b =>
79
79
{
80
80
var match = Context . API . FuzzySearch ( search , b . Name ) ;
81
- if ( ! match . IsSearchPrecisionScoreMet ( ) )
81
+ if ( ! match . IsSearchPrecisionScoreMet ( ) )
82
82
match = Context . API . FuzzySearch ( search , b . Url ) ;
83
83
return ( b , match ) ;
84
84
} )
@@ -90,7 +90,7 @@ public List<Result> Query(Query query)
90
90
91
91
return bookmarks . Select ( b => CreateResult ( b , 0 ) ) . ToList ( ) ;
92
92
}
93
-
93
+
94
94
private Result CreateResult ( Bookmark bookmark , int score ) => new ( )
95
95
{
96
96
Title = bookmark . Name ,
@@ -107,19 +107,19 @@ public List<Result> Query(Query query)
107
107
ContextData = bookmark . Url
108
108
} ;
109
109
110
- public async Task ReloadDataAsync ( )
110
+ public async Task ReloadDataAsync ( )
111
111
{
112
112
var ( bookmarks , discoveredFiles ) = await _bookmarkLoader . LoadBookmarksAsync ( _cancellationTokenSource . Token ) ;
113
-
113
+
114
114
// Atomically swap the list. This prevents the Query method from seeing a partially loaded list.
115
115
Volatile . Write ( ref _bookmarks , bookmarks ) ;
116
116
117
117
_bookmarkWatcher . UpdateWatchers ( discoveredFiles ) ;
118
-
118
+
119
119
// Fire and forget favicon processing to not block the UI
120
120
_ = _faviconService . ProcessBookmarkFavicons ( _bookmarks , _cancellationTokenSource . Token ) ;
121
121
}
122
-
122
+
123
123
private void OnSettingsPropertyChanged ( object ? sender , PropertyChangedEventArgs e )
124
124
{
125
125
if ( e . PropertyName is nameof ( Settings . LoadFirefoxBookmark ) )
@@ -134,7 +134,7 @@ private void OnCustomBrowsersChanged(object? sender, NotifyCollectionChangedEven
134
134
StartFirefoxBookmarkTimer ( ) ;
135
135
_ = ReloadDataAsync ( ) ;
136
136
}
137
-
137
+
138
138
private void OnBookmarkFileChanged ( )
139
139
{
140
140
_ = ReloadDataAsync ( ) ;
@@ -202,25 +202,25 @@ private async Task ReloadFirefoxBookmarksAsync()
202
202
203
203
var newFirefoxBookmarks = successfulResults . SelectMany ( r => r . Bookmarks ) . ToList ( ) ;
204
204
var successfulLoaderNames = successfulResults . Select ( r => r . Loader . Name ) . ToHashSet ( ) ;
205
-
205
+
206
206
var currentBookmarks = Volatile . Read ( ref _bookmarks ) ;
207
207
208
208
var otherBookmarks = currentBookmarks . Where ( b => ! successfulLoaderNames . Any ( name => b . Source . StartsWith ( name , StringComparison . OrdinalIgnoreCase ) ) ) ;
209
209
210
210
var newBookmarkList = otherBookmarks . Concat ( newFirefoxBookmarks ) . Distinct ( ) . ToList ( ) ;
211
211
212
212
Volatile . Write ( ref _bookmarks , newBookmarkList ) ;
213
-
213
+
214
214
Context . API . LogInfo ( nameof ( Main ) , $ "Periodic reload complete. Loaded { newFirefoxBookmarks . Count } Firefox bookmarks from { successfulLoaderNames . Count } sources.") ;
215
-
215
+
216
216
_ = _faviconService . ProcessBookmarkFavicons ( newFirefoxBookmarks , _cancellationTokenSource . Token ) ;
217
217
}
218
218
219
219
public Control CreateSettingPanel ( )
220
220
{
221
221
return new Views . SettingsControl ( _settings ) ;
222
222
}
223
-
223
+
224
224
public string GetTranslatedPluginTitle ( )
225
225
{
226
226
return Localize . flowlauncher_plugin_browserbookmark_plugin_name ( ) ;
@@ -230,12 +230,12 @@ public string GetTranslatedPluginDescription()
230
230
{
231
231
return Localize . flowlauncher_plugin_browserbookmark_plugin_description ( ) ;
232
232
}
233
-
233
+
234
234
public List < Result > LoadContextMenus ( Result selectedResult )
235
235
{
236
236
if ( selectedResult . ContextData is not string url )
237
237
return new List < Result > ( ) ;
238
-
238
+
239
239
return new List < Result >
240
240
{
241
241
new ( )
@@ -246,11 +246,11 @@ public List<Result> LoadContextMenus(Result selectedResult)
246
246
IcoPath = @"Images\copylink.png" ,
247
247
Action = _ =>
248
248
{
249
- try
249
+ try
250
250
{
251
251
Context . API . CopyToClipboard ( url ) ;
252
252
return true ;
253
- }
253
+ }
254
254
catch ( Exception ex )
255
255
{
256
256
Context . API . LogException ( nameof ( Main ) , "Failed to copy URL to clipboard" , ex ) ;
@@ -261,7 +261,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
261
261
}
262
262
} ;
263
263
}
264
-
264
+
265
265
public void Dispose ( )
266
266
{
267
267
_settings . PropertyChanged -= OnSettingsPropertyChanged ;
0 commit comments