fix issue with player look up with copy paste / predicate

release
Razmig Sarkissian 1 year ago
parent b15497f303
commit 37e184e199
  1. 2
      PadelClub/Extensions/String+Extensions.swift
  2. 4
      PadelClub/ViewModel/SearchViewModel.swift
  3. 2
      PadelClub/Views/Tournament/Screen/AddTeamView.swift

@ -14,7 +14,7 @@ extension String {
}
var trimmed: String {
trimmingCharacters(in: .whitespacesAndNewlines)
replaceCharactersFromSet(characterSet: .newlines).trimmingCharacters(in: .whitespacesAndNewlines)
}
func replaceCharactersFromSet(characterSet: CharacterSet, replacementString: String = "") -> String {

@ -156,8 +156,8 @@ class SearchViewModel: ObservableObject, Identifiable {
func orPredicate() -> NSPredicate? {
var predicates : [NSPredicate] = []
let allowedCharacterSet = CharacterSet.alphanumerics.union(.whitespaces)
let canonicalVersionWithoutPunctuation = searchText.canonicalVersion.components(separatedBy: allowedCharacterSet.inverted).joined()
let canonicalVersionWithPunctuation = searchText.canonicalVersionWithPunctuation
let canonicalVersionWithoutPunctuation = searchText.canonicalVersion.components(separatedBy: allowedCharacterSet.inverted).joined().trimmed
let canonicalVersionWithPunctuation = searchText.canonicalVersionWithPunctuation.trimmed
switch tokens.first {
case .none:
if canonicalVersionWithoutPunctuation.isEmpty == false {

@ -206,7 +206,7 @@ struct AddTeamView: View {
let allowedCharacterSet = CharacterSet.alphanumerics.union(.whitespaces)
// Remove all characters that are not in the allowedCharacterSet
let text = pasteField.canonicalVersion.components(separatedBy: allowedCharacterSet.inverted).joined()
let text = pasteField.canonicalVersion.components(separatedBy: allowedCharacterSet.inverted).joined().trimmed
let textStrings: [String] = text.components(separatedBy: .whitespacesAndNewlines)
let nonEmptyStrings: [String] = textStrings.compactMap { $0.isEmpty ? nil : $0 }

Loading…
Cancel
Save