|
|
|
|
@ -303,7 +303,7 @@ struct ClubSearchView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _importClub(clubToEdit: Club, clubMarker: ClubMarker) { |
|
|
|
|
if clubToEdit.creator == dataStore.user.id { |
|
|
|
|
if clubToEdit.hasBeenCreated(by: Store.main.userId) { |
|
|
|
|
if clubToEdit.name.isEmpty { |
|
|
|
|
clubToEdit.name = clubMarker.nom.capitalized |
|
|
|
|
clubToEdit.acronym = clubToEdit.automaticShortName().capitalized |
|
|
|
|
@ -314,17 +314,19 @@ struct ClubSearchView: View { |
|
|
|
|
clubToEdit.city = clubMarker.ville |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if displayContext == .addition { |
|
|
|
|
if displayContext == .addition && clubToEdit.hasBeenCreated(by: Store.main.userId) { |
|
|
|
|
do { |
|
|
|
|
try dataStore.clubs.addOrUpdate(instance: clubToEdit) |
|
|
|
|
if dataStore.user.clubs.contains(where: { $0 == clubToEdit.id }) == false { |
|
|
|
|
dataStore.user.clubs.append(clubToEdit.id) |
|
|
|
|
self.dataStore.saveUser() |
|
|
|
|
} |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if dataStore.user.clubs.contains(where: { $0 == clubToEdit.id }) == false { |
|
|
|
|
dataStore.user.clubs.append(clubToEdit.id) |
|
|
|
|
self.dataStore.saveUser() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dismiss() |
|
|
|
|
selection?(clubToEdit) |
|
|
|
|
} |
|
|
|
|
|