Skip to content
Closed

test #3869

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}
catch (Exception ex)
{
Main._context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
Main.Context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
continue;
}

Expand All @@ -55,12 +55,12 @@
// Load favicons after loading bookmarks
if (Main._settings.EnableFavicons)
{
var faviconDbPath = Path.Combine(profile, "Favicons");

Check warning on line 58 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Favicons` is not a recognized word. (unrecognized-spelling)
if (File.Exists(faviconDbPath))
{
Main._context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
Main.Context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>

Check warning on line 61 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`favicons` is not a recognized word. (unrecognized-spelling)
{
LoadFaviconsFromDb(faviconDbPath, profileBookmarks);

Check warning on line 63 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Favicons` is not a recognized word. (unrecognized-spelling)
});
}
}
Expand Down Expand Up @@ -125,19 +125,19 @@
}
else
{
Main._context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
Main.Context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
}
}
}

private void LoadFaviconsFromDb(string dbPath, List<Bookmark> bookmarks)

Check warning on line 133 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Favicons` is not a recognized word. (unrecognized-spelling)
{
FaviconHelper.LoadFaviconsFromDb(_faviconCacheDir, dbPath, (tempDbPath) =>

Check warning on line 135 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Favicons` is not a recognized word. (unrecognized-spelling)
{
// Since some bookmarks may have same favicon id, we need to record them to avoid duplicates
var savedPaths = new ConcurrentDictionary<string, bool>();

// Get favicons based on bookmarks concurrently

Check warning on line 140 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`favicons` is not a recognized word. (unrecognized-spelling)
Parallel.ForEach(bookmarks, bookmark =>
{
// Use read-only connection to avoid locking issues
Expand All @@ -159,7 +159,7 @@
using var cmd = connection.CreateCommand();
cmd.CommandText = @"
SELECT f.id, b.image_data
FROM favicons f

Check warning on line 162 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`favicons` is not a recognized word. (unrecognized-spelling)
JOIN favicon_bitmaps b ON f.id = b.icon_id
JOIN icon_mapping m ON f.id = m.icon_id
WHERE m.page_url LIKE @url
Expand All @@ -180,7 +180,7 @@

var faviconPath = Path.Combine(_faviconCacheDir, $"chromium_{domain}_{iconId}.png");

// Filter out duplicate favicons

Check warning on line 183 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`favicons` is not a recognized word. (unrecognized-spelling)
if (savedPaths.TryAdd(faviconPath, true))
{
FaviconHelper.SaveBitmapData(imageData, faviconPath);
Expand All @@ -190,7 +190,7 @@
}
catch (Exception ex)
{
Main._context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
Main.Context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
{
internal static MatchResult MatchProgram(Bookmark bookmark, string queryString)
{
var match = Main._context.API.FuzzySearch(queryString, bookmark.Name);
var match = Main.Context.API.FuzzySearch(queryString, bookmark.Name);
if (match.IsSearchPrecisionScoreMet())
return match;

return Main._context.API.FuzzySearch(queryString, bookmark.Url);
return Main.Context.API.FuzzySearch(queryString, bookmark.Url);
}

internal static List<Bookmark> LoadAllBookmarks(Settings setting)
Expand All @@ -31,7 +31,7 @@
{
// Add Firefox bookmarks
var mozBookmarks = new FirefoxBookmarkLoader();
allBookmarks.AddRange(mozBookmarks.GetBookmarks());

Check warning on line 34 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`moz` is not a recognized word. (unrecognized-spelling)
}

if (setting.LoadEdgeBookmark)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

// Updated query - removed favicon_id column
private const string QueryAllBookmarks = """
SELECT moz_places.url, moz_bookmarks.title

Check warning on line 28 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`moz` is not a recognized word. (unrecognized-spelling)
FROM moz_places
INNER JOIN moz_bookmarks ON (
moz_bookmarks.fk NOT NULL AND moz_bookmarks.title NOT NULL AND moz_bookmarks.fk = moz_places.id
Expand All @@ -49,7 +49,7 @@
}
catch (Exception ex)
{
Main._context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
Main.Context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
return bookmarks;
}

Expand Down Expand Up @@ -84,7 +84,7 @@
var faviconDbPath = Path.Combine(Path.GetDirectoryName(placesPath), "favicons.sqlite");
if (File.Exists(faviconDbPath))
{
Main._context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
Main.Context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
{
LoadFaviconsFromDb(faviconDbPath, bookmarks);
});
Expand All @@ -98,7 +98,7 @@
}
catch (Exception ex)
{
Main._context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
Main.Context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
}

// Delete temporary file
Expand All @@ -111,7 +111,7 @@
}
catch (Exception ex)
{
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
}

return bookmarks;
Expand Down Expand Up @@ -186,7 +186,7 @@
}
catch (Exception ex)
{
Main._context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
Main.Context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.3" >
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.7" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
}
catch (Exception ex1)
{
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
}
Main._context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
Main.Context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
return;
}

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

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

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

Expand Down
24 changes: 12 additions & 12 deletions Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex

internal static string _faviconCacheDir;

internal static PluginInitContext _context;
internal static PluginInitContext Context { get; private set; }

internal static Settings _settings;

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

public void Init(PluginInitContext context)
{
_context = context;
Context = context;

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

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

private static void LoadBookmarksIfEnabled()
{
if (_context.CurrentPluginMetadata.Disabled)
if (Context.CurrentPluginMetadata.Disabled)
{
// Don't load or monitor files if disabled
return;
Expand Down Expand Up @@ -84,7 +84,7 @@ public List<Result> Query(Query query)
Score = BookmarkLoader.MatchProgram(c, param).Score,
Action = _ =>
{
_context.API.OpenUrl(c.Url);
Context.API.OpenUrl(c.Url);

return true;
},
Expand All @@ -108,7 +108,7 @@ public List<Result> Query(Query query)
Score = 5,
Action = _ =>
{
_context.API.OpenUrl(c.Url);
Context.API.OpenUrl(c.Url);
return true;
},
ContextData = new BookmarkAttributes { Url = c.Url }
Expand Down Expand Up @@ -192,12 +192,12 @@ public static void ReloadAllBookmarks(bool disposeFileWatchers = true)

public string GetTranslatedPluginTitle()
{
return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_name");
return Localize.flowlauncher_plugin_browserbookmark_plugin_name();
}

public string GetTranslatedPluginDescription()
{
return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description");
return Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description");
}

public Control CreateSettingPanel()
Expand All @@ -211,20 +211,20 @@ public List<Result> LoadContextMenus(Result selectedResult)
{
new()
{
Title = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"),
SubTitle = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"),
Title = Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"),
SubTitle = Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"),
Action = _ =>
{
try
{
_context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);
Context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url);

return true;
}
catch (Exception e)
{
_context.API.LogException(ClassName, "Failed to set url in clipboard", e);
_context.API.ShowMsgError(_context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed"));
Context.API.LogException(ClassName, "Failed to set url in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed"));
return false;
}
},
Expand Down
Loading