Skip to content

Commit

Permalink
Merge pull request #406 from jibedoubleve/issue/399
Browse files Browse the repository at this point in the history
(#399) Refactoring of the code
  • Loading branch information
jibedoubleve authored Dec 20, 2023
2 parents 5c6b0d9 + dbb31b6 commit 64efb8d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Lanceur.Core/Decorators/EntityDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private EntityDecorator(TEntity entity)
public static IEnumerable<EntityDecorator<TEntity>> FromEnumerable(IEnumerable<TEntity> results) => results.Select(x => new EntityDecorator<TEntity>(x));

/// <summary>
/// Mark the contained <see cref="Entity"/> as updated in the database
/// Mark the contained <see cref="Entity"/> as to be updated in the database
/// </summary>
public void Soil() => IsDirty = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Lanceur.Core.Managers
{
public interface IThumbnailFixer
public interface IFavIconManager
{
#region Methods

Expand Down
8 changes: 4 additions & 4 deletions src/Lanceur.Infra.Win32/Thumbnails/ThumbnailManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public class ThumbnailManager : IThumbnailManager
private readonly IDbRepository _dbRepository;
private readonly IPackagedAppSearchService _searchService;
private readonly IAppLogger _log;
private readonly IThumbnailFixer _thumbnailFixer;
private readonly IFavIconManager _favIconManager;

#endregion Fields

#region Constructors

public ThumbnailManager(
IAppLoggerFactory loggerFactory,
IThumbnailFixer thumbnailFixer,
IFavIconManager favIconManager,
IDbRepository dbRepository,
IPackagedAppSearchService searchService)
{
_thumbnailFixer = thumbnailFixer;
_favIconManager = favIconManager;
_dbRepository = dbRepository;
_searchService = searchService;
_log = loggerFactory.GetLogger<ThumbnailManager>();
Expand Down Expand Up @@ -125,7 +125,7 @@ void RefreshCurrentThumbnail(EntityDecorator<QueryResult> query)
alias.Icon = webIcon;
alias.Thumbnail = favicon;

_ = _thumbnailFixer.RetrieveFaviconAsync(alias.FileName); // Fire & forget favicon retrieving
_ = _favIconManager.RetrieveFaviconAsync(alias.FileName); // Fire & forget favicon retrieving
_log.Trace($"Retrieved favicon for alias '{alias.Name}'. Favicon '{alias.FileName}'");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Lanceur.Infra.Managers
{
public class ThumbnailFixer : IThumbnailFixer
public class FavIconManager : IFavIconManager
{
#region Fields

Expand All @@ -24,14 +24,14 @@ public class ThumbnailFixer : IThumbnailFixer

#region Constructors

public ThumbnailFixer(IPackagedAppSearchService searchService, IFavIconDownloader favIconDownloader, IAppLoggerFactory appLoggerFactory)
public FavIconManager(IPackagedAppSearchService searchService, IFavIconDownloader favIconDownloader, IAppLoggerFactory appLoggerFactory)
{
ArgumentNullException.ThrowIfNull(searchService);
ArgumentNullException.ThrowIfNull(favIconDownloader);
ArgumentNullException.ThrowIfNull(appLoggerFactory);

_favIconDownloader = favIconDownloader;
_log = appLoggerFactory.GetLogger<ThumbnailFixer>();
_log = appLoggerFactory.GetLogger<FavIconManager>();
}

#endregion Constructors
Expand Down
4 changes: 2 additions & 2 deletions src/Lanceur/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ private static void RegisterServices()
l.Register<IClipboardService>(() => new WindowsClipboardService());
l.RegisterLazySingleton<IMacroManager>(() => new MacroManager(Assembly.GetExecutingAssembly()));
l.Register<IPluginManager>(() => new PluginManager(Get<IPluginStoreContext>()));
l.Register<IThumbnailManager>(() => new ThumbnailManager(Get<IAppLoggerFactory>(), Get<IThumbnailFixer>(), Get<IDbRepository>(), Get<IPackagedAppSearchService>()));
l.Register<IThumbnailManager>(() => new ThumbnailManager(Get<IAppLoggerFactory>(), Get<IFavIconManager>(), Get<IDbRepository>(), Get<IPackagedAppSearchService>()));
l.Register<IPackagedAppManager>(() => new PackagedAppManager());
l.Register<IPackagedAppSearchService>(() => new PackagedAppSearchService());
l.Register<IFavIconDownloader>(()=> new FavIconDownloader());
l.Register<IThumbnailFixer>(() => new ThumbnailFixer(Get<IPackagedAppSearchService>(), Get<IFavIconDownloader>(), Get<IAppLoggerFactory>()));
l.Register<IFavIconManager>(() => new FavIconManager(Get<IPackagedAppSearchService>(), Get<IFavIconDownloader>(), Get<IAppLoggerFactory>()));

// Formatters
l.Register<IStringFormatter>(() => new DefaultStringFormatter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class KeywordsViewModelBuilder

private IDbRepository _dbRepository;
private IAppLoggerFactory _loggerFactory;
private IThumbnailFixer _thumbnailFixer;
private IFavIconManager _favIconManager;
private TestSchedulerProvider _schedulerProvider;

#endregion Fields
Expand All @@ -36,9 +36,9 @@ public KeywordsViewModel Build()
);
}

public KeywordsViewModelBuilder With(IThumbnailFixer thumbnailFixer)
public KeywordsViewModelBuilder With(IFavIconManager favIconManager)
{
_thumbnailFixer = thumbnailFixer;
_favIconManager = favIconManager;
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Tests/Lanceur.Tests/ViewModels/KeywordViewModelShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void AbleToAddMultipleTimesAlias()
dbRepository.CheckNamesExist(Arg.Any<string[]>())
.Returns(new ExistingNameResponse(Array.Empty<string>()));

var packageValidator = Substitute.For<IThumbnailFixer>();
var packageValidator = Substitute.For<IFavIconManager>();

var vm = new KeywordsViewModelBuilder()
.With(scheduler)
Expand Down Expand Up @@ -100,7 +100,7 @@ public void AbleToRemoveSynonym()
var conversionService = new AutoMapperConverter(new Mapper(cfg));
var dbRepository = new SQLiteRepository(connectionMgr, logger, conversionService);

var packageValidator = Substitute.For<IThumbnailFixer>();
var packageValidator = Substitute.For<IFavIconManager>();
var vm = new KeywordsViewModelBuilder()
.With(scheduler)
.With(logger)
Expand Down

0 comments on commit 64efb8d

Please sign in to comment.