Explorar el Código

refactor: do not create duplicate tags

Sam Jaffe hace 3 semanas
padre
commit
bab8a8bb72
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      Todos/View/TagBarView.swift

+ 3 - 1
Todos/View/TagBarView.swift

@@ -24,7 +24,9 @@ struct TagBarView: View {
       .scaledToFit()
       TextField("Tag", text: $active)
         .onSubmit {
-          tags.append(Tag(id: active))
+          if !tags.contains(where: { $0.id.caseInsensitiveCompare(active) == .orderedSame }) {
+            tags.append(Tag(id: active))
+          }
           active = ""
         }
     }