diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 57d5523..a9d7428 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3650,7 +3650,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.22; + MARKETING_VERSION = 1.1.23; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3695,7 +3695,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.22; + MARKETING_VERSION = 1.1.23; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/PadelClub/Data/PlayerRegistration.swift b/PadelClub/Data/PlayerRegistration.swift index 44ef214..3717437 100644 --- a/PadelClub/Data/PlayerRegistration.swift +++ b/PadelClub/Data/PlayerRegistration.swift @@ -240,7 +240,7 @@ final class PlayerRegistration: BasePlayerRegistration, SideStorable { } } - func updateRank(from sources: [CSVParser], lastRank: Int) async throws { + func updateRank(from sources: [CSVParser], lastRank: Int?) async throws { #if DEBUG_TIME let start = Date() defer { diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index ed51d3f..a576d5e 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1215,9 +1215,8 @@ defer { rankSourceDate = newDate // Fetch current month data only once - let monthData = currentMonthData() - - + var monthData = currentMonthData() + if monthData == nil { async let lastRankWoman = SourceFileManager.shared.getUnrankValue(forMale: false, rankSourceDate: rankSourceDate) async let lastRankMan = SourceFileManager.shared.getUnrankValue(forMale: true, rankSourceDate: rankSourceDate) @@ -1233,10 +1232,12 @@ defer { } catch { Logger.error(error) } + + monthData = newMonthData } - let lastRankMan = monthData?.maleUnrankedValue ?? 0 - let lastRankWoman = monthData?.femaleUnrankedValue ?? 0 + let lastRankMan = monthData?.maleUnrankedValue + let lastRankWoman = monthData?.femaleUnrankedValue var chunkedParsers: [CSVParser] = [] if let providedSources { diff --git a/PadelClub/Views/Tournament/FileImportView.swift b/PadelClub/Views/Tournament/FileImportView.swift index e25ff4d..4e2353d 100644 --- a/PadelClub/Views/Tournament/FileImportView.swift +++ b/PadelClub/Views/Tournament/FileImportView.swift @@ -499,7 +499,16 @@ struct FileImportView: View { private func _validate(tournament: Tournament) async { let filteredTeams = filteredTeams(tournament: tournament) + let lastDataSource: String? = DataStore.shared.appSettings.lastDataSource + var _mostRecentDateAvailable: Date? { + guard let lastDataSource else { return nil } + return URL.importDateFormatter.date(from: lastDataSource) + } + if let rankSourceDate = _mostRecentDateAvailable { + tournament.rankSourceDate = rankSourceDate + _save() + } tournament.importTeams(filteredTeams) validatedTournamentIds.insert(tournament.id) diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 4b1671e..74f7667 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -278,6 +278,7 @@ struct InscriptionManagerView: View { } .sheet(isPresented: $presentImportView, onDismiss: { _setHash() + currentRankSourceDate = tournament.rankSourceDate }) { NavigationStack { FileImportView(defaultFileProvider: tournament.isAnimation() ? .custom : .frenchFederation) @@ -293,8 +294,11 @@ struct InscriptionManagerView: View { _setHash() } .onChange(of: currentRankSourceDate) { - if let currentRankSourceDate, tournament.rankSourceDate != currentRankSourceDate { + if let currentRankSourceDate, tournament.rankSourceDate != currentRankSourceDate, unsortedPlayers.isEmpty == false { confirmUpdateRank = true + } else { + tournament.rankSourceDate = currentRankSourceDate + _save() } } .sheet(isPresented: $confirmUpdateRank, onDismiss: {