mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use api functions instead of project reference for code quality
This commit is contained in:
parent
2c6fdc0b2e
commit
0430eea2fd
4 changed files with 16 additions and 28 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Flow.Launcher.Infrastructure;
|
|
||||||
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
||||||
using Flow.Launcher.Plugin.SharedModels;
|
using Flow.Launcher.Plugin.SharedModels;
|
||||||
|
|
||||||
|
|
@ -10,11 +9,11 @@ internal static class BookmarkLoader
|
||||||
{
|
{
|
||||||
internal static MatchResult MatchProgram(Bookmark bookmark, string queryString)
|
internal static MatchResult MatchProgram(Bookmark bookmark, string queryString)
|
||||||
{
|
{
|
||||||
var match = StringMatcher.FuzzySearch(queryString, bookmark.Name);
|
var match = Main._context.API.FuzzySearch(queryString, bookmark.Name);
|
||||||
if (match.IsSearchPrecisionScoreMet())
|
if (match.IsSearchPrecisionScoreMet())
|
||||||
return match;
|
return match;
|
||||||
|
|
||||||
return StringMatcher.FuzzySearch(queryString, bookmark.Url);
|
return Main._context.API.FuzzySearch(queryString, bookmark.Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<Bookmark> LoadAllBookmarks(Settings setting)
|
internal static List<Bookmark> LoadAllBookmarks(Settings setting)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
using System;
|
||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Flow.Launcher.Infrastructure.Logger;
|
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.BrowserBookmark;
|
namespace Flow.Launcher.Plugin.BrowserBookmark;
|
||||||
|
|
||||||
public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
||||||
{
|
{
|
||||||
|
private static readonly string ClassName = nameof(FirefoxBookmarkLoaderBase);
|
||||||
|
|
||||||
private readonly string _faviconCacheDir;
|
private readonly string _faviconCacheDir;
|
||||||
|
|
||||||
protected FirefoxBookmarkLoaderBase()
|
protected FirefoxBookmarkLoaderBase()
|
||||||
|
|
@ -52,7 +53,7 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a copy to avoid lock issues with the original file
|
// Use a copy to avoid lock issues with the original file
|
||||||
|
|
@ -93,12 +94,12 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to delete temporary favicon DB: {tempDbPath}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to load Firefox bookmarks: {placesPath}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bookmarks;
|
return bookmarks;
|
||||||
|
|
@ -177,7 +178,7 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to extract Firefox favicon: {bookmark.Url}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,12 +193,12 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to delete temporary favicon DB: {tempDbPath}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to load Firefox favicon DB: {faviconDbPath}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to load Firefox favicon DB: {faviconDbPath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,7 +219,7 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Failed to save image: {outputPath}", ex);
|
Main._context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
|
|
||||||
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
|
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Flow.Launcher.Infrastructure.Logger;
|
|
||||||
using Flow.Launcher.Plugin.BrowserBookmark.Commands;
|
using Flow.Launcher.Plugin.BrowserBookmark.Commands;
|
||||||
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
||||||
using Flow.Launcher.Plugin.BrowserBookmark.Views;
|
using Flow.Launcher.Plugin.BrowserBookmark.Views;
|
||||||
|
|
@ -15,7 +14,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark;
|
||||||
|
|
||||||
public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable
|
public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable
|
||||||
{
|
{
|
||||||
private static PluginInitContext _context;
|
internal static PluginInitContext _context;
|
||||||
|
|
||||||
private static List<Bookmark> _cachedBookmarks = new();
|
private static List<Bookmark> _cachedBookmarks = new();
|
||||||
|
|
||||||
|
|
@ -23,16 +22,6 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
|
||||||
|
|
||||||
private static bool _initialized = false;
|
private static bool _initialized = false;
|
||||||
|
|
||||||
public static PluginInitContext GetContext()
|
|
||||||
{
|
|
||||||
return _context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetPluginDirectory()
|
|
||||||
{
|
|
||||||
return _context?.CurrentPluginMetadata?.PluginDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
@ -223,7 +212,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
var message = "Failed to set url in clipboard";
|
var message = "Failed to set url in clipboard";
|
||||||
Log.Exception("Main", message, e, "LoadContextMenus");
|
_context.API.LogException(nameof(Main), message, e);
|
||||||
|
|
||||||
_context.API.ShowMsg(message);
|
_context.API.ShowMsg(message);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue