Skip to content

Commit

Permalink
move majority of favicon code to app bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy committed Nov 18, 2024
1 parent d7cc5ae commit e053b36
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 74 deletions.
37 changes: 0 additions & 37 deletions Core/CoreFaviconsHelper.swift

This file was deleted.

1 change: 1 addition & 0 deletions Core/FaviconRequestModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// limitations under the License.
//

import Core
import Kingfisher

class FaviconRequestModifier: ImageDownloadRequestModifier {
Expand Down
5 changes: 3 additions & 2 deletions Core/NotFoundCachingDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// limitations under the License.
//

import Core
import Kingfisher

class NotFoundCachingDownloader: ImageDownloader {
Expand Down Expand Up @@ -46,7 +47,7 @@ class NotFoundCachingDownloader: ImageDownloader {
}

func noFaviconsFound(forDomain domain: String) {
guard let hashedKey = CoreFaviconsHelper.defaultResource(forDomain: domain, sourcesProvider: sourcesProvider)?.cacheKey else { return }
guard let hashedKey = FaviconsHelper.defaultResource(forDomain: domain, sourcesProvider: sourcesProvider)?.cacheKey else { return }
notFoundCache[hashedKey] = Date().timeIntervalSince1970
}

Expand All @@ -56,7 +57,7 @@ class NotFoundCachingDownloader: ImageDownloader {
}

func shouldDownload(forDomain domain: String, referenceDate: Date = Date()) -> Bool {
guard let hashedKey = CoreFaviconsHelper.defaultResource(forDomain: domain, sourcesProvider: sourcesProvider)?.cacheKey else { return false }
guard let hashedKey = FaviconsHelper.defaultResource(forDomain: domain, sourcesProvider: sourcesProvider)?.cacheKey else { return false }
if let cacheAddTime = notFoundCache[hashedKey],
referenceDate.timeIntervalSince1970 - cacheAddTime < Self.expiry {
return false
Expand Down
8 changes: 6 additions & 2 deletions Core/SyncBookmarksAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public final class SyncBookmarksAdapter {
public let databaseCleaner: BookmarkDatabaseCleaner
public let syncDidCompletePublisher: AnyPublisher<Void, Never>
let syncErrorHandler: SyncErrorHandling
private let faviconStoring: FaviconStoring

@UserDefaultsWrapper(key: .syncDidMigrateToImprovedListsHandling, defaultValue: false)
private var didMigrateToImprovedListsHandling: Bool
Expand All @@ -88,10 +89,13 @@ public final class SyncBookmarksAdapter {

public init(database: CoreDataDatabase,
favoritesDisplayModeStorage: FavoritesDisplayModeStoring,
syncErrorHandler: SyncErrorHandling) {
syncErrorHandler: SyncErrorHandling,
faviconStoring: FaviconStoring) {
self.database = database
self.favoritesDisplayModeStorage = favoritesDisplayModeStorage
self.syncErrorHandler = syncErrorHandler
self.faviconStoring = faviconStoring

syncDidCompletePublisher = syncDidCompleteSubject.eraseToAnyPublisher()
databaseCleaner = BookmarkDatabaseCleaner(
bookmarkDatabase: database,
Expand Down Expand Up @@ -172,7 +176,7 @@ public final class SyncBookmarksAdapter {
database: database,
stateStore: stateStore,
fetcher: FaviconFetcher(),
faviconStore: Favicons.shared,
faviconStore: faviconStoring,
errorEvents: BookmarksFaviconsFetcherErrorHandler()
)
}
Expand Down
6 changes: 4 additions & 2 deletions Core/SyncDataProviders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ public class SyncDataProviders: DataProvidersSource {
secureVaultErrorReporter: SecureVaultReporting,
settingHandlers: [SettingSyncHandler],
favoritesDisplayModeStorage: FavoritesDisplayModeStoring,
syncErrorHandler: SyncErrorHandling
syncErrorHandler: SyncErrorHandling,
faviconStoring: FaviconStoring
) {
self.bookmarksDatabase = bookmarksDatabase
self.secureVaultFactory = secureVaultFactory
self.secureVaultErrorReporter = secureVaultErrorReporter
bookmarksAdapter = SyncBookmarksAdapter(database: bookmarksDatabase,
favoritesDisplayModeStorage: favoritesDisplayModeStorage,
syncErrorHandler: syncErrorHandler)
syncErrorHandler: syncErrorHandler,
faviconStoring: faviconStoring)
credentialsAdapter = SyncCredentialsAdapter(secureVaultFactory: secureVaultFactory,
secureVaultErrorReporter: secureVaultErrorReporter,
syncErrorHandler: syncErrorHandler)
Expand Down
Loading

0 comments on commit e053b36

Please sign in to comment.