Replace 'lastUpdated' with 'lastUpdate'

This commit is contained in:
Davide 2024-10-28 17:14:49 +01:00
parent 0d383ec792
commit 639dee55ee
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
6 changed files with 19 additions and 17 deletions

View File

@ -41,7 +41,7 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
"state" : { "state" : {
"revision" : "69b2ed730986d684195a39b592155b3384f3d857" "revision" : "efbf2e135b04e9c0f67b5d2b517c5e13a75c50f6"
} }
}, },
{ {

View File

@ -28,7 +28,7 @@ let package = Package(
], ],
dependencies: [ dependencies: [
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"), // .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(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", from: "0.9.1"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"),

View File

@ -46,7 +46,7 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository {
private let providersSubject: CurrentValueSubject<[ProviderMetadata], Never> private let providersSubject: CurrentValueSubject<[ProviderMetadata], Never>
private let lastUpdatedSubject: CurrentValueSubject<[ProviderID: Date], Never> private let lastUpdateSubject: CurrentValueSubject<[ProviderID: Date], Never>
private let providersController: NSFetchedResultsController<CDProviderV3> private let providersController: NSFetchedResultsController<CDProviderV3>
@ -54,7 +54,7 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository {
self.context = context self.context = context
self.backgroundContext = backgroundContext self.backgroundContext = backgroundContext
providersSubject = CurrentValueSubject([]) providersSubject = CurrentValueSubject([])
lastUpdatedSubject = CurrentValueSubject([:]) lastUpdateSubject = CurrentValueSubject([:])
let request = CDProviderV3.fetchRequest() let request = CDProviderV3.fetchRequest()
request.sortDescriptors = [ request.sortDescriptors = [
@ -83,8 +83,8 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository {
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }
nonisolated var lastUpdatedPublisher: AnyPublisher<[ProviderID: Date], Never> { nonisolated var lastUpdatePublisher: AnyPublisher<[ProviderID: Date], Never> {
lastUpdatedSubject lastUpdateSubject
.removeDuplicates() .removeDuplicates()
.eraseToAnyPublisher() .eraseToAnyPublisher()
} }
@ -131,7 +131,7 @@ actor CDProviderRepositoryV3: NSObject, ProviderRepository {
providerRequest.predicate = predicate providerRequest.predicate = predicate
let providers = try providerRequest.execute() let providers = try providerRequest.execute()
if let provider = providers.first { if let provider = providers.first {
provider.lastUpdate = infrastructure.lastUpdated provider.lastUpdate = infrastructure.lastUpdate
} }
// delete all provider entities // delete all provider entities
@ -174,6 +174,6 @@ extension CDProviderRepositoryV3: NSFetchedResultsControllerDelegate {
} }
let mapper = DomainMapper() let mapper = DomainMapper()
providersSubject.send(entities.compactMap(mapper.provider(from:))) providersSubject.send(entities.compactMap(mapper.provider(from:)))
lastUpdatedSubject.send(mapper.lastUpdated(from: entities)) lastUpdateSubject.send(mapper.lastUpdate(from: entities))
} }
} }

View File

@ -88,7 +88,7 @@ struct DomainMapper {
) )
} }
func lastUpdated(from entities: [CDProviderV3]) -> [ProviderID: Date] { func lastUpdate(from entities: [CDProviderV3]) -> [ProviderID: Date] {
entities.reduce(into: [:]) { entities.reduce(into: [:]) {
guard let id = $1.providerId, guard let id = $1.providerId,
let lastUpdate = $1.lastUpdate else { let lastUpdate = $1.lastUpdate else {

View File

@ -61,7 +61,7 @@ struct ReportIssueButton {
guard let id = installedProfile?.firstProviderModuleWithMetadata?.1.id else { guard let id = installedProfile?.firstProviderModuleWithMetadata?.1.id else {
return nil return nil
} }
let lastUpdate = providerManager.lastUpdated(for: id) let lastUpdate = providerManager.lastUpdate(for: id)
return (id, lastUpdate) return (id, lastUpdate)
} }
} }

View File

@ -124,23 +124,25 @@ private extension ProviderContentModifier {
} }
var supportedProviders: [ProviderMetadata] { var supportedProviders: [ProviderMetadata] {
providerManager.providers.filter { providerManager
.providers
.filter {
$0.supports(Entity.Configuration.self) $0.supports(Entity.Configuration.self)
} }
} }
var lastUpdated: Date? { var lastUpdate: Date? {
guard let providerId else { guard let providerId else {
return nil return nil
} }
return providerManager.lastUpdated(for: providerId) return providerManager.lastUpdate(for: providerId)
} }
var lastUpdatedString: String? { var lastUpdatedString: String? {
guard let lastUpdated else { guard let lastUpdate else {
return providerManager.isLoading ? Strings.Providers.LastUpdated.loading : nil return providerManager.isLoading ? Strings.Providers.LastUpdated.loading : nil
} }
return Strings.Providers.lastUpdated(lastUpdated.timestamp) return Strings.Providers.lastUpdated(lastUpdate.timestamp)
} }
} }