Skip to content

Commit

Permalink
Fix: #407
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter van den Hamer committed Aug 4, 2024
1 parent 39c7a96 commit d9d2a75
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 62 deletions.
10 changes: 5 additions & 5 deletions Photo Club Hub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
D0621E892AE2E47B000FFADB /* MemberPortfolio+refreshFirstImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0621E882AE2E47B000FFADB /* MemberPortfolio+refreshFirstImage.swift */; };
D0654D032C5586AD00171D8B /* BellusImagoMembersProvider+insertOnlineMemberData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0654D022C5586AD00171D8B /* BellusImagoMembersProvider+insertOnlineMemberData.swift */; };
D0654D052C55978A00171D8B /* fcBellusImago.level2.json in Resources */ = {isa = PBXBuildFile; fileRef = D0654D042C55978A00171D8B /* fcBellusImago.level2.json */; };
D06754A02942B23F00C0AB08 /* FotogroepWaalreMembersProvide+enumHTMLPageLoadingState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D067549F2942B23F00C0AB08 /* FotogroepWaalreMembersProvide+enumHTMLPageLoadingState.swift */; };
D06BE9332A4F870B0055B3B1 /* ifDebugUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06BE9322A4F870B0055B3B1 /* ifDebugUtils.swift */; };
D06D08DE2C28835D00872BC2 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D0CEAECE2B2E1134005AE47D /* Settings.bundle */; };
D0795CEC294FCCC200FA62A8 /* ShapeStyle+Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0795CEB294FCCC200FA62A8 /* ShapeStyle+Colors.swift */; };
Expand All @@ -63,7 +62,6 @@
D0831A32277F72590049AB84 /* Photographer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A25277F72590049AB84 /* Photographer.swift */; };
D0831A34277F72590049AB84 /* BellusImagoMembersProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A28277F72590049AB84 /* BellusImagoMembersProvider.swift */; };
D0831A35277F72590049AB84 /* PreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A29277F72590049AB84 /* PreferencesViewModel.swift */; };
D0831A36277F72590049AB84 /* FotogroepWaalreMembersProvider+insertSomeHardcodedMemberData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A2B277F72590049AB84 /* FotogroepWaalreMembersProvider+insertSomeHardcodedMemberData.swift */; };
D0831A37277F72590049AB84 /* FotogroepWaalreMembersProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A2C277F72590049AB84 /* FotogroepWaalreMembersProvider.swift */; };
D0831A38277F72590049AB84 /* Organization.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A2D277F72590049AB84 /* Organization.swift */; };
D0831A45277F731C0049AB84 /* String+Capitalize.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0831A41277F731C0049AB84 /* String+Capitalize.swift */; };
Expand All @@ -78,6 +76,8 @@
D0ADF4AE27922DCA00535432 /* MemberRolesAndStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0ADF4AD27922DCA00535432 /* MemberRolesAndStatus.swift */; };
D0AE1B7527889E8600E0100E /* OrganizationListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AE1B7427889E8600E0100E /* OrganizationListView.swift */; };
D0AE1B782788A19500E0100E /* WhoIsWhoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AE1B772788A19500E0100E /* WhoIsWhoListView.swift */; };
D0AEDF572C5FC6930050E877 /* FotogroepWaalreMembersProvide+enumHTMLPageLoadingState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D067549F2942B23F00C0AB08 /* FotogroepWaalreMembersProvide+enumHTMLPageLoadingState.swift */; };
D0AEDF592C5FC6A40050E877 /* FotogroepWaalreMembersProvider+insertOnlineHTMLMemberData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0968F652A76F8A00096987A /* FotogroepWaalreMembersProvider+insertOnlineHTMLMemberData.swift */; };
D0B260B72958FC2D00B73E1A /* FGWMembersProvider+extractName.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B260B62958FC2D00B73E1A /* FGWMembersProvider+extractName.swift */; };
D0B32BB32C15C51A009FF8E7 /* AppVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0B32BB22C15C51A009FF8E7 /* AppVersion.swift */; };
D0B52497277F9A4B00927BCA /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0B52495277F9A4B00927BCA /* Localizable.strings */; };
Expand Down Expand Up @@ -433,9 +433,9 @@
children = (
D0621E832AE2DF8E000FFADB /* IndividualClubs */,
D08416952B2FC07F000F316D /* Lists */,
D08416942B2FC061000F316D /* ListReaders */,
D0447C872BA510AF00982A1E /* LocalizedRemark.swift */,
D0447C862BA510AF00982A1E /* Language.swift */,
D08416942B2FC061000F316D /* ListReaders */,
D0621E822AE2DF1B000FFADB /* MemberPortfolio */,
D029C4D02C54096200ABA977 /* Organization */,
D0F5EE852C54ED750028C9A6 /* Photographer */,
Expand Down Expand Up @@ -821,6 +821,7 @@
D0831A34277F72590049AB84 /* BellusImagoMembersProvider.swift in Sources */,
D0FE77E52BB9AEE900272077 /* ItemFilterStatsEnum.swift in Sources */,
D0C53BDD2ABF3ADF000722A1 /* PersonName.swift in Sources */,
D0AEDF592C5FC6A40050E877 /* FotogroepWaalreMembersProvider+insertOnlineHTMLMemberData.swift in Sources */,
D0ADF4AE27922DCA00535432 /* MemberRolesAndStatus.swift in Sources */,
D0447C882BA510AF00982A1E /* Language.swift in Sources */,
D06BE9332A4F870B0055B3B1 /* ifDebugUtils.swift in Sources */,
Expand All @@ -830,6 +831,7 @@
D0447C892BA510AF00982A1E /* LocalizedRemark.swift in Sources */,
D0A0B6852AA930E90078DE9A /* Photo_Club_Hub.xcdatamodeld in Sources */,
D0EEF48F2C2844290086419D /* Settings.swift in Sources */,
D0AEDF572C5FC6930050E877 /* FotogroepWaalreMembersProvide+enumHTMLPageLoadingState.swift in Sources */,
D0831A22277F72270049AB84 /* MemberPortfolioListView.swift in Sources */,
D0C8E3A22BB81B4A00348D97 /* ItemFilterStatsView.swift in Sources */,
D0654D032C5586AD00171D8B /* BellusImagoMembersProvider+insertOnlineMemberData.swift in Sources */,
Expand All @@ -844,7 +846,6 @@
D08281362959CA7000D9C232 /* FGWMembersProvider+extractExternalURL.swift in Sources */,
D0795CEC294FCCC200FA62A8 /* ShapeStyle+Colors.swift in Sources */,
D0EB533C295775240061613B /* Crosshairs.swift in Sources */,
D0831A36277F72590049AB84 /* FotogroepWaalreMembersProvider+insertSomeHardcodedMemberData.swift in Sources */,
D0621E892AE2E47B000FFADB /* MemberPortfolio+refreshFirstImage.swift in Sources */,
D0831A20277F72270049AB84 /* FilteredOrganizationView.swift in Sources */,
D05124852C42BE2D00D94B81 /* Level2JsonReader.swift in Sources */,
Expand Down Expand Up @@ -882,7 +883,6 @@
D044646527FCE7C100990613 /* UIDevice+IsIPad.swift in Sources */,
D05E451E27EF2A2C00D31327 /* ReadmeView.swift in Sources */,
D01D2B6227D3BBDC00E2FE41 /* View+Navigate.swift in Sources */,
D06754A02942B23F00C0AB08 /* FotogroepWaalreMembersProvide+enumHTMLPageLoadingState.swift in Sources */,
D082BE912957806800FF0812 /* LogoPath.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
8 changes: 4 additions & 4 deletions Photo Club Hub/Model/OrganizationIdPlus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
import Foundation

struct OrganizationIdPlus: Sendable { // PhotoClubID plus non-identifying nickname
var id: PhotoClubId
var id: OrganizationID
var nickname: String

init(fullName: String, // initializer hides PhotoClubId level
town: String,
nickname: String) {
let id = PhotoClubId(fullName: fullName, town: town)
let id = OrganizationID(fullName: fullName, town: town)
self.id = id
self.nickname = nickname
}

init(id: PhotoClubId, // initializer exposes PhotoClubId level
init(id: OrganizationID, // initializer exposes PhotoClubId level
nickname: String) {
self.id = id
self.nickname = nickname
Expand All @@ -30,7 +30,7 @@ struct OrganizationIdPlus: Sendable { // PhotoClubID plus non-identifying nickna
var town: String { id.town }
}

public struct PhotoClubId: Hashable, Sendable { // hashable because PhotoClubId is used as dictionary key
public struct OrganizationID: Hashable, Sendable { // hashable because PhotoClubId is used as dictionary key
var fullName: String
var town: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@
<memberEntity name="LocalizedRemark"/>
<memberEntity name="Language"/>
</configuration>
</model>
</model>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct FilteredOrganizationView: View, Sendable {

@FetchRequest var fetchedOrganizations: FetchedResults<Organization>

@State private var cameraPositions: [PhotoClubId: MapCameraPosition] = [:] // location of camera per club
@State private var cameraPositions: [OrganizationID: MapCameraPosition] = [:] // location of camera per club
@State private var mapSelection: MKMapItem? // selected Anotation, if any

private let searchText: Binding<String>
Expand Down Expand Up @@ -252,7 +252,7 @@ struct FilteredOrganizationView: View, Sendable {
cameraPositions[organization.id] = mapCameraPosition // return MapCameraPosition and don't use input param
}

private func cameraPositionBinding(for key: PhotoClubId) -> Binding<MapCameraPosition> {
private func cameraPositionBinding(for key: OrganizationID) -> Binding<MapCameraPosition> {
let defaultCameraPosition = MapCameraPosition.region(MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 0, longitude: 6.52396), // island on the equator
latitudinalMeters: 100000, longitudinalMeters: 100000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ extension FotogroepWaalreMembersProvider {
let portfoliosInClub = try bgContext.fetch(fetchRequest)

for portfolio in portfoliosInClub {
// PhotoClubHubApp.antiZombiePinningOfMemberPortfolios.insert(portfolio)
portfolio.refreshFirstImage()
}
try bgContext.save() // persist first images for Fotogroep Waalre
Expand Down Expand Up @@ -123,11 +122,11 @@ extension FotogroepWaalreMembersProvider {
self.addMember(bgContext: bgContext,
organization: organization, personName: personName,
optionalFields: PhotographerOptionalFields(
bornDT: bornDT,
eMail: eMail,
phoneNumber: phoneNumber,
photographerWebsite: URL(string: externalURL) ?? nil
)
bornDT: bornDT,
eMail: eMail,
phoneNumber: phoneNumber,
photographerWebsite: URL(string: externalURL) ?? nil
)
)
}

Expand All @@ -152,24 +151,24 @@ extension FotogroepWaalreMembersProvider {
optionalFields: optionalFields)

_ = MemberPortfolio.findCreateUpdate(
bgContext: bgContext,
organization: organization,
photographer: photographer,
optionalFields: MemberOptionalFields(
level3URL: self.generateInternalURL(using: personName.fullNameWithoutParenthesizedRole),
memberRolesAndStatus: MemberRolesAndStatus(
role: [:], // FG Waalre HTML input file doesn't contain role information
status: [
.former: !self.isCurrentMember(name: personName.fullNameWithParenthesizedRole,
includeProspectiveMembers: true),
.coach: self.isMentor(name: personName.fullNameWithParenthesizedRole),
.prospective: self.isProspectiveMember(
name: personName.fullNameWithParenthesizedRole
)
]
bgContext: bgContext,
organization: organization,
photographer: photographer,
optionalFields: MemberOptionalFields(
level3URL: self.generateInternalURL(using: personName.fullNameWithoutParenthesizedRole),
memberRolesAndStatus: MemberRolesAndStatus(
role: [:], // FG Waalre HTML input file doesn't contain role information
status: [
.former: !self.isCurrentMember(name: personName.fullNameWithParenthesizedRole,
includeProspectiveMembers: true),
.coach: self.isMentor(name: personName.fullNameWithParenthesizedRole),
.prospective: self.isProspectiveMember(
name: personName.fullNameWithParenthesizedRole
)
]
)
)
)
)
}

private func generateInternalURL(using name: String) -> URL? { // only use standard ASCII A...Z,a...z in URLs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class FotogroepWaalreMembersProvider { // WWDC21 Earthquakes also uses a Class h
init(bgContext: NSManagedObjectContext) {
// following is asynchronous, but not documented as such using async/await
bgContext.perform { // done asynchronously by CoreData
// self.insertSomeHardcodedMemberData(bgContext: bgContext)
self.insertOnlineMemberData(bgContext: bgContext)
do {
if bgContext.hasChanges { // optimisation
Expand Down
53 changes: 29 additions & 24 deletions Photo Club Hub/ViewModel/ListReaders/Level2JsonReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,24 @@ class Level2JsonReader { // normally running on a background thread
familyName: familyName),
organization: club, // used for debug messages
optionalFields: PhotographerOptionalFields()) // updated later

let memberPortfolio: MemberPortfolio
if member["optional"].exists() { // could contain photographerOptionalFields, memberOptionalFields, or both.
loadPhotographerAndMemberOptionals(bgContext: bgContext,
jsonOptionals: member["optional"],
photographer: photographer, club: club)
memberPortfolio = loadPhotographerAndMemberOptionals(bgContext: bgContext,
jsonOptionals: member["optional"],
photographer: photographer, club: club)
} else {
_ = MemberPortfolio.findCreateUpdate(bgContext: bgContext,
organization: club,
photographer: photographer,
optionalFields: MemberOptionalFields(
memberRolesAndStatus: MemberRolesAndStatus(jsonRoles: [:],
memberPortfolio = MemberPortfolio.findCreateUpdate(bgContext: bgContext,
organization: club,
photographer: photographer,
optionalFields: MemberOptionalFields(
memberRolesAndStatus: MemberRolesAndStatus(
jsonRoles: [:],
jsonStatus: [:])
)
)
)
}
memberPortfolio.refreshFirstImage()
}

private func loadClubOptionals(bgContext: NSManagedObjectContext,
Expand All @@ -264,7 +268,7 @@ class Level2JsonReader { // normally running on a background thread

_ = Organization.findCreateUpdate(context: bgContext,
organizationTypeEnum: OrganizationTypeEnum.club,
idPlus: OrganizationIdPlus(id: PhotoClubId(fullName: club.fullName,
idPlus: OrganizationIdPlus(id: OrganizationID(fullName: club.fullName,
town: club.town),
nickname: club.nickName),
optionalFields: OrganizationOptionalFields(
Expand All @@ -280,7 +284,7 @@ class Level2JsonReader { // normally running on a background thread
private func loadPhotographerAndMemberOptionals(bgContext: NSManagedObjectContext,
jsonOptionals: JSON,
photographer: Photographer,
club: Organization) {
club: Organization) -> MemberPortfolio {
let birthday: String? = jsonOptionals["birthday"].exists() ? jsonOptionals["birthday"].stringValue : nil

let photographerWebsite: URL? = jsonOptionalsToURL(jsonOptionals: jsonOptionals, key: "website")
Expand Down Expand Up @@ -312,19 +316,20 @@ class Level2JsonReader { // normally running on a background thread
)

// ...while some attributes are at the Photographer as Member of club level
_ = MemberPortfolio.findCreateUpdate(bgContext: bgContext,
organization: club,
photographer: photographer,
removeMember: false, // remove records for members that no longer on list
optionalFields: MemberOptionalFields(
featuredImage: featuredImage,
featuredImageThumbnail: featuredImage,
level3URL: level3URL, // address of portfolio data for this member
memberRolesAndStatus: memberRolesAndStatus,
fotobondNumber: fotobondNumber,
membershipStartDate: membershipStartDate,
membershipEndDate: membershipEndDate
)
return MemberPortfolio.findCreateUpdate(
bgContext: bgContext,
organization: club,
photographer: photographer,
removeMember: false, // remove records for members that no longer on list
optionalFields: MemberOptionalFields(
featuredImage: featuredImage,
featuredImageThumbnail: featuredImage,
level3URL: level3URL, // address of portfolio data for this member
memberRolesAndStatus: memberRolesAndStatus,
fotobondNumber: fotobondNumber,
membershipStartDate: membershipStartDate,
membershipEndDate: membershipEndDate
)
)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import RegexBuilder // for OneOrMore, Capture, etc
extension MemberPortfolio {

func refreshFirstImage() {
let clubsUsingJuiceBox: [OrganizationID] = [ // strings have to be precise ;-)
OrganizationID(fullName: "Fotogroep Waalre", town: "Waalre"),
OrganizationID(fullName: "Fotogroep de Gender", town: "Eindhoven")
]
guard clubsUsingJuiceBox.contains(organization.id) else { return }
let organizationTown: String = self.organization.fullNameTown
guard organizationTown == "Fotogroep Waalre" else { return }

if let urlIndex = URL(string: self.level3URL.absoluteString + "config.xml") { // assume JuiceBox Pro
ifDebugPrint("\(organizationTown): starting refreshFirstImage() \(urlIndex.absoluteString) in background")
Expand Down
Loading

0 comments on commit d9d2a75

Please sign in to comment.