Skip to content

Commit 4620229

Browse files
author
Jon Petersson
committed
Allow deleting custom lists
1 parent d035970 commit 4620229

File tree

6 files changed

+33
-23
lines changed

6 files changed

+33
-23
lines changed

ios/MullvadSettings/CustomListRepository.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public enum CustomRelayListError: LocalizedError, Equatable {
1818
switch self {
1919
case .duplicateName:
2020
NSLocalizedString(
21-
"DUPLICATE_CUSTOM_LIST_ERROR",
22-
tableName: "CustomListRepository",
21+
"DUPLICATE_CUSTOM_LISTS_ERROR",
22+
tableName: "CustomLists",
2323
value: "Name is already taken.",
2424
comment: ""
2525
)

ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class AddCustomListCoordinator: Coordinator, Presentable, Presenting {
4242
controller.delegate = self
4343

4444
controller.navigationItem.title = NSLocalizedString(
45-
"CUSTOM_LIST_NAVIGATION_EDIT_TITLE",
45+
"CUSTOM_LISTS_NAVIGATION_EDIT_TITLE",
4646
tableName: "CustomLists",
4747
value: "New custom list",
4848
comment: ""
4949
)
5050

5151
controller.saveBarButton.title = NSLocalizedString(
52-
"CUSTOM_LIST_NAVIGATION_CREATE_BUTTON",
52+
"CUSTOM_LISTS_NAVIGATION_CREATE_BUTTON",
5353
tableName: "CustomLists",
5454
value: "Create",
5555
comment: ""

ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift

+21-12
Original file line numberDiff line numberDiff line change
@@ -158,26 +158,35 @@ class CustomListViewController: UIViewController {
158158
}
159159

160160
private func onDelete() {
161-
// TODO: Show error dialog.
162-
delegate?.customListDidDelete()
163-
}
164-
165-
private func showSaveErrorAlert() {
166161
let presentation = AlertPresentation(
167-
id: "api-custom-lists-save-list-alert",
162+
id: "api-custom-lists-delete-list-alert",
168163
icon: .alert,
169164
message: NSLocalizedString(
170-
"CUSTOM_LISTS_SAVE_ERROR_PROMPT",
171-
tableName: "APIAccess",
172-
value: "List name is already taken.",
165+
"CUSTOM_LISTS_DELETE_PROMPT",
166+
tableName: "CustomLists",
167+
value: "Delete custom list \(subject.value.name)?",
173168
comment: ""
174169
),
175170
buttons: [
176171
AlertAction(
177172
title: NSLocalizedString(
178-
"CUSTOM_LISTS_OK_BUTTON",
179-
tableName: "APIAccess",
180-
value: "Got it!",
173+
"CUSTOM_LISTS_DELETE_BUTTON",
174+
tableName: "CustomLists",
175+
value: "Delete",
176+
comment: ""
177+
),
178+
style: .destructive,
179+
handler: {
180+
self.interactor.deleteCustomList(id: self.subject.value.id)
181+
self.dismiss(animated: true)
182+
self.delegate?.customListDidDelete()
183+
}
184+
),
185+
AlertAction(
186+
title: NSLocalizedString(
187+
"CUSTOM_LISTS_CANCEL_BUTTON",
188+
tableName: "CustomLists",
189+
value: "Cancel",
181190
comment: ""
182191
),
183192
style: .default

ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import UIKit
1414
class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
1515
let navigationController: UINavigationController
1616
let customListInteractor: CustomListInteractorProtocol
17+
let customList: CustomList
1718

1819
var presentedViewController: UIViewController {
1920
navigationController
@@ -23,18 +24,20 @@ class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
2324

2425
init(
2526
navigationController: UINavigationController,
26-
customListInteractor: CustomListInteractorProtocol
27+
customListInteractor: CustomListInteractorProtocol,
28+
customList: CustomList
2729
) {
2830
self.navigationController = navigationController
2931
self.customListInteractor = customListInteractor
32+
self.customList = customList
3033
}
3134

3235
func start() {
3336
let subject = CurrentValueSubject<CustomListViewModel, Never>(
3437
CustomListViewModel(
35-
id: UUID(),
36-
name: "A list",
37-
locations: [],
38+
id: customList.id,
39+
name: customList.name,
40+
locations: customList.locations,
3841
tableSections: [.name, .editLocations, .deleteList]
3942
)
4043
)

ios/MullvadVPN/Coordinators/SelectLocationCoordinator.swift

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import MullvadTypes
1111
import Routing
1212
import UIKit
1313

14-
import MullvadSettings
15-
1614
class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCacheTrackerObserver {
1715
private let tunnelManager: TunnelManager
1816
private let relayCacheTracker: RelayCacheTracker

ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class EditAccessMethodViewController: UITableViewController {
333333
id: "api-access-methods-delete-method-alert",
334334
icon: .alert,
335335
message: NSLocalizedString(
336-
"METHOD_SETTINGS_SAVE_PROMPT",
336+
"METHOD_SETTINGS_DELETE_PROMPT",
337337
tableName: "APIAccess",
338338
value: "Delete \(methodName)?",
339339
comment: ""

0 commit comments

Comments
 (0)