Skip to content

Commit

Permalink
Merge branch 'custom-list-crashes-when-naming-a-list-with-the-name-of…
Browse files Browse the repository at this point in the history
…-an-ios-599'
  • Loading branch information
buggmagnet committed Apr 15, 2024
2 parents 8f8bd1d + c3d575e commit 6973de9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ios/MullvadSettings/CustomListRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ public struct CustomListRepository: CustomListRepositoryProtocol {
public func save(list: CustomList) throws {
var lists = fetchAll()

if let index = lists.firstIndex(where: { $0.id == list.id }) {
if let listWithSameName = lists.first(where: { $0.name.caseInsensitiveCompare(list.name) == .orderedSame }),
listWithSameName.id != list.id {
throw CustomRelayListError.duplicateName
} else if let index = lists.firstIndex(where: { $0.id == list.id }) {
lists[index] = list
try write(lists)
} else if lists.contains(where: { $0.name == list.name }) {
throw CustomRelayListError.duplicateName
} else {
lists.append(list)
try write(lists)
Expand Down

0 comments on commit 6973de9

Please sign in to comment.