We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f8bd1d commit c3d575eCopy full SHA for c3d575e
ios/MullvadSettings/CustomListRepository.swift
@@ -39,11 +39,12 @@ public struct CustomListRepository: CustomListRepositoryProtocol {
39
public func save(list: CustomList) throws {
40
var lists = fetchAll()
41
42
- if let index = lists.firstIndex(where: { $0.id == list.id }) {
+ if let listWithSameName = lists.first(where: { $0.name.caseInsensitiveCompare(list.name) == .orderedSame }),
43
+ listWithSameName.id != list.id {
44
+ throw CustomRelayListError.duplicateName
45
+ } else if let index = lists.firstIndex(where: { $0.id == list.id }) {
46
lists[index] = list
47
try write(lists)
- } else if lists.contains(where: { $0.name == list.name }) {
- throw CustomRelayListError.duplicateName
48
} else {
49
lists.append(list)
50
0 commit comments