From 639dee55eed5b88b4c4049b4464928736eb8de4e Mon Sep 17 00:00:00 2001 From: Davide Date: Mon, 28 Oct 2024 17:14:49 +0100 Subject: [PATCH] Replace 'lastUpdated' with 'lastUpdate' --- .../xcshareddata/swiftpm/Package.resolved | 2 +- Passepartout/Library/Package.swift | 2 +- .../CDProviderRepositoryV3.swift | 12 ++++++------ .../Sources/AppDataProviders/Domain/Mapper.swift | 2 +- .../Views/Diagnostics/ReportIssueButton.swift | 2 +- .../Views/Provider/ProviderContentModifier.swift | 16 +++++++++------- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f47a001a..de0b3b05 100644 --- a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -41,7 +41,7 @@ "kind" : "remoteSourceControl", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "state" : { - "revision" : "69b2ed730986d684195a39b592155b3384f3d857" + "revision" : "efbf2e135b04e9c0f67b5d2b517c5e13a75c50f6" } }, { diff --git a/Passepartout/Library/Package.swift b/Passepartout/Library/Package.swift index 93c0a4f1..144d9b9d 100644 --- a/Passepartout/Library/Package.swift +++ b/Passepartout/Library/Package.swift @@ -28,7 +28,7 @@ let package = Package( ], dependencies: [ // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"), - .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "69b2ed730986d684195a39b592155b3384f3d857"), + .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "efbf2e135b04e9c0f67b5d2b517c5e13a75c50f6"), // .package(path: "../../../passepartoutkit-source"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), diff --git a/Passepartout/Library/Sources/AppDataProviders/CDProviderRepositoryV3.swift b/Passepartout/Library/Sources/AppDataProviders/CDProviderRepositoryV3.swift index 707cb709..3d116565 100644 --- a/Passepartout/Library/Sources/AppDataProviders/CDProviderRepositoryV3.swift +++ b/Passepartout/Library/Sources/AppDataProviders/CDProviderRepositoryV3.swift @@ -46,7 +46,7 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository { private let providersSubject: CurrentValueSubject<[ProviderMetadata], Never> - private let lastUpdatedSubject: CurrentValueSubject<[ProviderID: Date], Never> + private let lastUpdateSubject: CurrentValueSubject<[ProviderID: Date], Never> private let providersController: NSFetchedResultsController @@ -54,7 +54,7 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository { self.context = context self.backgroundContext = backgroundContext providersSubject = CurrentValueSubject([]) - lastUpdatedSubject = CurrentValueSubject([:]) + lastUpdateSubject = CurrentValueSubject([:]) let request = CDProviderV3.fetchRequest() request.sortDescriptors = [ @@ -83,8 +83,8 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository { .eraseToAnyPublisher() } - nonisolated var lastUpdatedPublisher: AnyPublisher<[ProviderID: Date], Never> { - lastUpdatedSubject + nonisolated var lastUpdatePublisher: AnyPublisher<[ProviderID: Date], Never> { + lastUpdateSubject .removeDuplicates() .eraseToAnyPublisher() } @@ -131,7 +131,7 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository { providerRequest.predicate = predicate let providers = try providerRequest.execute() if let provider = providers.first { - provider.lastUpdate = infrastructure.lastUpdated + provider.lastUpdate = infrastructure.lastUpdate } // delete all provider entities @@ -174,6 +174,6 @@ extension CDProviderRepositoryV3: NSFetchedResultsControllerDelegate { } let mapper = DomainMapper() providersSubject.send(entities.compactMap(mapper.provider(from:))) - lastUpdatedSubject.send(mapper.lastUpdated(from: entities)) + lastUpdateSubject.send(mapper.lastUpdate(from: entities)) } } diff --git a/Passepartout/Library/Sources/AppDataProviders/Domain/Mapper.swift b/Passepartout/Library/Sources/AppDataProviders/Domain/Mapper.swift index de5d2ffb..79c66a2f 100644 --- a/Passepartout/Library/Sources/AppDataProviders/Domain/Mapper.swift +++ b/Passepartout/Library/Sources/AppDataProviders/Domain/Mapper.swift @@ -88,7 +88,7 @@ struct DomainMapper { ) } - func lastUpdated(from entities: [CDProviderV3]) -> [ProviderID: Date] { + func lastUpdate(from entities: [CDProviderV3]) -> [ProviderID: Date] { entities.reduce(into: [:]) { guard let id = $1.providerId, let lastUpdate = $1.lastUpdate else { diff --git a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift index 39e40a74..4e2d473a 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Diagnostics/ReportIssueButton.swift @@ -61,7 +61,7 @@ struct ReportIssueButton { guard let id = installedProfile?.firstProviderModuleWithMetadata?.1.id else { return nil } - let lastUpdate = providerManager.lastUpdated(for: id) + let lastUpdate = providerManager.lastUpdate(for: id) return (id, lastUpdate) } } diff --git a/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift b/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift index d2ce8410..2a502952 100644 --- a/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift +++ b/Passepartout/Library/Sources/AppUI/Views/Provider/ProviderContentModifier.swift @@ -124,23 +124,25 @@ private extension ProviderContentModifier { } var supportedProviders: [ProviderMetadata] { - providerManager.providers.filter { - $0.supports(Entity.Configuration.self) - } + providerManager + .providers + .filter { + $0.supports(Entity.Configuration.self) + } } - var lastUpdated: Date? { + var lastUpdate: Date? { guard let providerId else { return nil } - return providerManager.lastUpdated(for: providerId) + return providerManager.lastUpdate(for: providerId) } var lastUpdatedString: String? { - guard let lastUpdated else { + guard let lastUpdate else { return providerManager.isLoading ? Strings.Providers.LastUpdated.loading : nil } - return Strings.Providers.lastUpdated(lastUpdated.timestamp) + return Strings.Providers.lastUpdated(lastUpdate.timestamp) } }