fix some warnings

multistore
Razmig Sarkissian 2 years ago
parent 3a9a075035
commit fb1e503fbb
  1. 8
      PadelClub/Data/Tournament.swift
  2. 4
      PadelClub/Extensions/Locale+Extensions.swift
  3. 8
      PadelClub/Utils/CloudConvert.swift
  4. 6
      PadelClub/Utils/ContactManager.swift
  5. 6
      PadelClub/ViewModel/MatchScheduler.swift
  6. 2
      PadelClub/Views/Cashier/CashierView.swift
  7. 2
      PadelClub/Views/Components/FortuneWheelView.swift
  8. 4
      PadelClub/Views/Match/MatchDetailView.swift
  9. 2
      PadelClub/Views/Navigation/MainView.swift
  10. 2
      PadelClub/Views/Round/RoundView.swift
  11. 6
      PadelClub/Views/Score/EditScoreView.swift
  12. 39
      PadelClub/Views/Score/SetInputView.swift
  13. 4
      PadelClub/Views/Score/SetLabelView.swift
  14. 6
      PadelClub/Views/Tournament/FileImportView.swift

@ -150,9 +150,9 @@ class Tournament : ModelObject, Storable {
}
func state() -> Tournament.State {
if currentCanceled == true {
return .canceled
}
// if currentCanceled == true {
// return .canceled
// }
if (groupStageCount > 0 && groupStages().isEmpty == false)
|| rounds().isEmpty == false {
return .build
@ -377,7 +377,7 @@ class Tournament : ModelObject, Storable {
}
func selectedSortedTeams() -> [TeamRegistration] {
let start = Date()
//let start = Date()
var _sortedTeams : [TeamRegistration] = []
let _teams = unsortedTeams().filter({ $0.walkOut == false })

@ -12,8 +12,8 @@ extension Locale {
static func countries() -> [String] {
var countries: [String] = []
for countryCode in Locale.isoRegionCodes {
if let countryName = Locale.current.localizedString(forRegionCode: countryCode) {
for countryCode in Locale.Region.isoRegions {
if let countryName = Locale.current.localizedString(forRegionCode: countryCode.identifier) {
countries.append(countryName)
}
}

@ -60,7 +60,7 @@ class CloudConvert {
request.httpBody = postData
let task = try await URLSession.shared.data(for: request)
print("tried: \(request.url)")
//print("tried: \(request.url)")
if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: task.0) {
print("errorResponse.error", errorResponse.error)
throw CloudConvertionError.serviceError(errorResponse)
@ -77,7 +77,7 @@ class CloudConvert {
uploadRequest.httpMethod = "PUT"
let uploadTask = try await URLSession.shared.upload(for: uploadRequest, fromFile: url)
print("tried: \(uploadRequest.url)")
//print("tried: \(uploadRequest.url)")
if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: uploadTask.0) {
print("errorResponse.error", errorResponse.error)
throw CloudConvertionError.serviceError(errorResponse)
@ -94,7 +94,7 @@ class CloudConvert {
request.httpMethod = "GET"
let task = try await URLSession.shared.data(for: request)
print("tried: \(request.url)")
//print("tried: \(request.url)")
if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: task.0) {
print("errorResponse.error", errorResponse.error)
throw CloudConvertionError.serviceError(errorResponse)
@ -117,7 +117,7 @@ class CloudConvert {
throw CloudConvertionError.serviceError(errorResponse)
}
print("tried: \(downloadRequest.url)")
//print("tried: \(downloadRequest.url)")
let dataResponse = try JSONDecoder().decode(DataResponse.self, from: downloadTask.0)
if let decodedData = Data(base64Encoded: dataResponse.data.content), let string = String(data: decodedData, encoding: .utf8) {
return string

@ -57,7 +57,7 @@ extension ContactType {
static func callingGroupStageMessage(tournament: Tournament?, startDate: Date?, roundLabel: String, matchFormat: MatchFormat?) -> String {
let useFullCustomMessage = DataStore.shared.appSettings.callUseFullCustomMessage ?? false
let useFullCustomMessage = DataStore.shared.appSettings.callUseFullCustomMessage
if useFullCustomMessage {
return callingGroupStageCustomMessage(tournament: tournament, startDate: startDate, roundLabel: roundLabel)
@ -72,11 +72,11 @@ extension ContactType {
let localizedCalled = "convoqué" + (tournament?.tournamentCategory == .women ? "e" : "") + "s"
var formatMessage: String? {
(DataStore.shared.appSettings.callDisplayFormat ?? false) ? matchFormat?.computedLongLabel.appending(".") : nil
(DataStore.shared.appSettings.callDisplayFormat) ? matchFormat?.computedLongLabel.appending(".") : nil
}
var entryFeeMessage: String? {
(DataStore.shared.appSettings.callDisplayEntryFee ?? false) ? tournament?.entryFeeMessage : nil
(DataStore.shared.appSettings.callDisplayEntryFee) ? tournament?.entryFeeMessage : nil
}
var computedMessage: String {

@ -502,7 +502,6 @@ class MatchScheduler {
}
func updateBracketSchedule(tournament: Tournament, fromRoundId roundId: String?, fromMatchId matchId: String?, startDate: Date) {
let numberOfCourtsAvailablePerRotation: Int = tournament.courtCount
courtsUnavailability = tournament.eventObject?.courtsUnavailability
let upperRounds = tournament.rounds()
@ -522,7 +521,7 @@ class MatchScheduler {
}
}
var flattenedMatches = rounds.flatMap { round in
let flattenedMatches = rounds.flatMap { round in
round._matches().filter({ $0.disabled == false }).sorted(by: \.index)
}
@ -575,7 +574,7 @@ class MatchScheduler {
let courts : [Int]? = initialCourts.isEmpty ? nil : initialCourts
print("initial available courts at beginning: \(courts)")
print("initial available courts at beginning: \(courts ?? [])")
let roundDispatch = self.roundDispatcher(numberOfCourtsAvailablePerRotation: tournament.courtCount, flattenedMatches: flattenedMatches, dispatcherStartDate: startDate, initialCourts: courts)
@ -608,7 +607,6 @@ class MatchScheduler {
}
func updateSchedule(tournament: Tournament) {
let numberOfCourtsAvailablePerRotation: Int = tournament.courtCount
courtsUnavailability = tournament.eventObject?.courtsUnavailability
let lastDate = updateGroupStageSchedule(tournament: tournament)
updateBracketSchedule(tournament: tournament, fromRoundId: nil, fromMatchId: nil, startDate: lastDate)

@ -21,7 +21,7 @@ struct CashierView: View {
init(tournament: Tournament, teams: [TeamRegistration]) {
self.tournaments = [tournament]
self.teams = teams
if teams.filter { $0.callDate != nil }.isEmpty {
if teams.filter({ $0.callDate != nil }).isEmpty {
_sortOption = .init(wrappedValue: .teamRank)
} else {
_sortOption = .init(wrappedValue: .callDate)

@ -74,7 +74,7 @@ struct SpinDrawView: View {
Text(time, style: .timer)
}
if let selectedIndex {
if selectedIndex != nil {
Section {
Text(validationLabel(drawee: drawCount, result: segments[draws.last!.drawIndex]))
if autoMode == false || drawCount == drawees.count {

@ -406,7 +406,7 @@ struct MatchDetailView: View {
} label: {
Text("Horaire")
}
.onChange(of: startDateSetup, perform: { value in
.onChange(of: startDateSetup) {
switch startDateSetup {
case .customDate:
break
@ -415,7 +415,7 @@ struct MatchDetailView: View {
case .inMinutes(let minutes):
startDate = Date().addingTimeInterval(Double(minutes) * 60)
}
})
}
}
if match.startDate != nil || startDateSetup == .customDate {

@ -91,7 +91,7 @@ struct MainView: View {
}
private func _checkSourceFileAvailability() async {
print(dataStore.appSettings.lastDataSource)
print("dataStore.appSettings.lastDataSource :", dataStore.appSettings.lastDataSource ?? "none")
print("check internet")
print("check files on internet")
print("check if any files on internet are more recent than here")

@ -21,7 +21,7 @@ struct RoundView: View {
if isEditingTournamentSeed.wrappedValue == false {
//(where: { $0.isDisabled() == false || isEditingTournamentSeed.wrappedValue })
if loserRounds.isEmpty == false, let first = loserRounds.first {
if loserRounds.isEmpty == false {
let correspondingLoserRoundTitle = round.correspondingLoserRoundTitle()
Section {
NavigationLink {

@ -47,7 +47,7 @@ struct EditScoreView: View {
Spacer()
MatchTypeSmallSelectionView(selectedFormat: $matchDescriptor.matchFormat, format: "Format")
.onChange(of: matchDescriptor.matchFormat) { newValue in
.onChange(of: matchDescriptor.matchFormat) {
matchDescriptor.setDescriptors.removeAll()
matchDescriptor.addNewSet()
}
@ -55,8 +55,8 @@ struct EditScoreView: View {
}
ForEach($matchDescriptor.setDescriptors) { $setDescriptor in
SetInputView(setDescriptor: $setDescriptor)
.onChange(of: setDescriptor.hasEnded) { hasEnded in
if hasEnded {
.onChange(of: setDescriptor.hasEnded) {
if setDescriptor.hasEnded {
if matchDescriptor.hasEnded == false {
matchDescriptor.addNewSet()
}

@ -137,8 +137,8 @@ struct SetInputView: View {
}
}
}
.onChange(of: setDescriptor.valueTeamOne, perform: { newValue in
if let newValue {
.onChange(of: setDescriptor.valueTeamOne) {
if let newValue = setDescriptor.valueTeamOne {
if newValue == setFormat.scoreToWin - 1 && setFormat.tieBreak == 8 {
setDescriptor.valueTeamTwo = setFormat.scoreToWin
} else if newValue == setFormat.scoreToWin - 2 && setFormat.tieBreak == 8 {
@ -154,14 +154,14 @@ struct SetInputView: View {
}
}
})
.onChange(of: setDescriptor.valueTeamTwo, perform: { newValue in
}
.onChange(of: setDescriptor.valueTeamTwo) {
if setDescriptor.valueTeamOne != nil && setDescriptor.valueTeamTwo != nil {
showSetInputView = false
}
})
.onChange(of: setDescriptor.tieBreakValueTeamOne, perform: { newValue in
if let newValue, setDescriptor.tieBreakValueTeamTwo == nil {
}
.onChange(of: setDescriptor.tieBreakValueTeamOne) {
if let newValue = setDescriptor.tieBreakValueTeamOne, setDescriptor.tieBreakValueTeamTwo == nil {
if newValue > 7 {
setDescriptor.tieBreakValueTeamTwo = newValue - 2
}
@ -172,7 +172,7 @@ struct SetInputView: View {
setDescriptor.tieBreakValueTeamTwo = 7
}
}
else if let newValue, let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo {
else if let newValue = setDescriptor.tieBreakValueTeamOne, let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo {
if newValue > 6 && tieBreakValueTeamTwo < newValue {
setDescriptor.tieBreakValueTeamTwo = newValue - 2
}
@ -187,31 +187,28 @@ struct SetInputView: View {
showTieBreakInputView = false
}
}
})
.onChange(of: setDescriptor.tieBreakValueTeamTwo, perform: { newValue in
}
.onChange(of: setDescriptor.tieBreakValueTeamTwo) {
if let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne, tieBreakValueTeamOne <= 5 {
showTieBreakInputView = false
} else {
if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo {
if let newValue {
if newValue > 6 && tieBreakValueTeamTwo > setDescriptor.tieBreakValueTeamOne ?? 0 {
setDescriptor.tieBreakValueTeamOne = newValue - 2
}
if newValue > 4 && tieBreakValueTeamTwo < setDescriptor.tieBreakValueTeamOne ?? 0 {
setDescriptor.tieBreakValueTeamOne = newValue + 2
}
if tieBreakValueTeamTwo > 6 && tieBreakValueTeamTwo > setDescriptor.tieBreakValueTeamOne ?? 0 {
setDescriptor.tieBreakValueTeamOne = tieBreakValueTeamTwo - 2
}
if tieBreakValueTeamTwo > 4 && tieBreakValueTeamTwo < setDescriptor.tieBreakValueTeamOne ?? 0 {
setDescriptor.tieBreakValueTeamOne = tieBreakValueTeamTwo + 2
}
}
if let newValue, let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne {
if newValue < 6 && tieBreakValueTeamOne == 7 {
if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo, let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne {
if tieBreakValueTeamTwo < 6 && tieBreakValueTeamOne == 7 {
showTieBreakInputView = false
}
}
}
})
}
.listRowSeparator(.hidden)
}
}

@ -42,10 +42,10 @@ struct SetLabelView: View {
.scaleEffect(0.7)
}
}
.onChange(of: initialValueLeft) { newValue in
.onChange(of: initialValueLeft) {
valueLeft = initialValueLeft ?? 0
}
.onChange(of: initialValueRight) { newValue in
.onChange(of: initialValueRight) {
valueRight = initialValueRight ?? 0
}
.onAppear {

@ -225,9 +225,9 @@ struct FileImportView: View {
ToolbarItem(placement: .topBarTrailing) {
ButtonValidateView {
if false { //selectedOptions.contains(.deleteBeforeImport)
try? dataStore.teamRegistrations.delete(contentOfs: tournament.unsortedTeams())
}
// if false { //selectedOptions.contains(.deleteBeforeImport)
// try? dataStore.teamRegistrations.delete(contentOfs: tournament.unsortedTeams())
// }
if true { //selectedOptions.contains(.notFoundAreWalkOut)
let previousTeams = filteredTeams.compactMap({ $0.previousTeam })

Loading…
Cancel
Save