Skip to content

Commit 3b45900

Browse files
committed
test
1 parent 65cfb29 commit 3b45900

File tree

6 files changed

+32
-28
lines changed

6 files changed

+32
-28
lines changed

Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected List<Bookmark> LoadBookmarks(string browserDataPath, string name)
4545
}
4646
catch (Exception ex)
4747
{
48-
Main._context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
48+
Main.Context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
4949
continue;
5050
}
5151

@@ -58,7 +58,7 @@ protected List<Bookmark> LoadBookmarks(string browserDataPath, string name)
5858
var faviconDbPath = Path.Combine(profile, "Favicons");
5959
if (File.Exists(faviconDbPath))
6060
{
61-
Main._context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
61+
Main.Context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
6262
{
6363
LoadFaviconsFromDb(faviconDbPath, profileBookmarks);
6464
});
@@ -125,7 +125,7 @@ private static void EnumerateFolderBookmark(JsonElement folderElement, ICollecti
125125
}
126126
else
127127
{
128-
Main._context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
128+
Main.Context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
129129
}
130130
}
131131
}
@@ -190,7 +190,7 @@ ORDER BY b.width DESC
190190
}
191191
catch (Exception ex)
192192
{
193-
Main._context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
193+
Main.Context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
194194
}
195195
finally
196196
{

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ internal static class BookmarkLoader
99
{
1010
internal static MatchResult MatchProgram(Bookmark bookmark, string queryString)
1111
{
12-
var match = Main._context.API.FuzzySearch(queryString, bookmark.Name);
12+
var match = Main.Context.API.FuzzySearch(queryString, bookmark.Name);
1313
if (match.IsSearchPrecisionScoreMet())
1414
return match;
1515

16-
return Main._context.API.FuzzySearch(queryString, bookmark.Url);
16+
return Main.Context.API.FuzzySearch(queryString, bookmark.Url);
1717
}
1818

1919
internal static List<Bookmark> LoadAllBookmarks(Settings setting)

Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
4949
}
5050
catch (Exception ex)
5151
{
52-
Main._context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
52+
Main.Context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
5353
return bookmarks;
5454
}
5555

@@ -84,7 +84,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
8484
var faviconDbPath = Path.Combine(Path.GetDirectoryName(placesPath), "favicons.sqlite");
8585
if (File.Exists(faviconDbPath))
8686
{
87-
Main._context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
87+
Main.Context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
8888
{
8989
LoadFaviconsFromDb(faviconDbPath, bookmarks);
9090
});
@@ -98,7 +98,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
9898
}
9999
catch (Exception ex)
100100
{
101-
Main._context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
101+
Main.Context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
102102
}
103103

104104
// Delete temporary file
@@ -111,7 +111,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
111111
}
112112
catch (Exception ex)
113113
{
114-
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
114+
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
115115
}
116116

117117
return bookmarks;
@@ -186,7 +186,7 @@ ORDER BY i.width DESC -- Select largest icon available
186186
}
187187
catch (Exception ex)
188188
{
189-
Main._context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
189+
Main.Context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
190190
}
191191
finally
192192
{

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696

9797
<ItemGroup>
9898
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
99+
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.3" >
100+
<PrivateAssets>all</PrivateAssets>
101+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
102+
</PackageReference>
99103
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.7" />
100104
</ItemGroup>
101105

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
2727
}
2828
catch (Exception ex1)
2929
{
30-
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
30+
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
3131
}
32-
Main._context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
32+
Main.Context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
3333
return;
3434
}
3535

@@ -39,7 +39,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
3939
}
4040
catch (Exception ex)
4141
{
42-
Main._context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex);
42+
Main.Context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex);
4343
}
4444

4545
// Delete temporary file
@@ -49,7 +49,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
4949
}
5050
catch (Exception ex)
5151
{
52-
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
52+
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
5353
}
5454
}
5555

@@ -61,7 +61,7 @@ public static void SaveBitmapData(byte[] imageData, string outputPath)
6161
}
6262
catch (Exception ex)
6363
{
64-
Main._context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
64+
Main.Context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
6565
}
6666
}
6767

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
1919

2020
internal static string _faviconCacheDir;
2121

22-
internal static PluginInitContext _context;
22+
internal static PluginInitContext Context { get; private set; }
2323

2424
internal static Settings _settings;
2525

@@ -29,7 +29,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
2929

3030
public void Init(PluginInitContext context)
3131
{
32-
_context = context;
32+
Context = context;
3333

3434
_settings = context.API.LoadSettingJsonStorage<Settings>();
3535

@@ -42,7 +42,7 @@ public void Init(PluginInitContext context)
4242

4343
private static void LoadBookmarksIfEnabled()
4444
{
45-
if (_context.CurrentPluginMetadata.Disabled)
45+
if (Context.CurrentPluginMetadata.Disabled)
4646
{
4747
// Don't load or monitor files if disabled
4848
return;
@@ -84,7 +84,7 @@ public List<Result> Query(Query query)
8484
Score = BookmarkLoader.MatchProgram(c, param).Score,
8585
Action = _ =>
8686
{
87-
_context.API.OpenUrl(c.Url);
87+
Context.API.OpenUrl(c.Url);
8888

8989
return true;
9090
},
@@ -108,7 +108,7 @@ public List<Result> Query(Query query)
108108
Score = 5,
109109
Action = _ =>
110110
{
111-
_context.API.OpenUrl(c.Url);
111+
Context.API.OpenUrl(c.Url);
112112
return true;
113113
},
114114
ContextData = new BookmarkAttributes { Url = c.Url }
@@ -192,12 +192,12 @@ public static void ReloadAllBookmarks(bool disposeFileWatchers = true)
192192

193193
public string GetTranslatedPluginTitle()
194194
{
195-
return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_name");
195+
return Localize.flowlauncher_plugin_browserbookmark_plugin_name();
196196
}
197197

198198
public string GetTranslatedPluginDescription()
199199
{
200-
return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description");
200+
return Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description");
201201
}
202202

203203
public Control CreateSettingPanel()
@@ -211,20 +211,20 @@ public List<Result> LoadContextMenus(Result selectedResult)
211211
{
212212
new()
213213
{
214-
Title = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"),
215-
SubTitle = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"),
214+
Title = Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"),
215+
SubTitle = Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"),
216216
Action = _ =>
217217
{
218218
try
219219
{
220-
_context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);
220+
Context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);
221221

222222
return true;
223223
}
224224
catch (Exception e)
225225
{
226-
_context.API.LogException(ClassName, "Failed to set url in clipboard", e);
227-
_context.API.ShowMsgError(_context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed"));
226+
Context.API.LogException(ClassName, "Failed to set url in clipboard", e);
227+
Context.API.ShowMsgError(Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed"));
228228
return false;
229229
}
230230
},

0 commit comments

Comments
 (0)