@@ -22,7 +22,7 @@ class ListCustomListCoordinator: Coordinator, Presentable, Presenting {
22
22
navigationController
23
23
}
24
24
25
- var didFinish : ( ( ) -> Void ) ?
25
+ var didFinish : ( ( ListCustomListCoordinator ) -> Void ) ?
26
26
27
27
init (
28
28
navigationController: UINavigationController ,
@@ -39,28 +39,29 @@ class ListCustomListCoordinator: Coordinator, Presentable, Presenting {
39
39
}
40
40
41
41
func start( ) {
42
- listViewController. didFinish = didFinish
43
- listViewController. didSelectItem = {
44
- self . edit ( list: $0)
42
+ listViewController. didFinish = { [ weak self] in
43
+ guard let self else { return }
44
+ didFinish ? ( self )
45
+ }
46
+ listViewController. didSelectItem = { [ weak self] in
47
+ self ? . edit ( list: $0)
45
48
}
46
49
47
50
navigationController. pushViewController ( listViewController, animated: false )
48
51
}
49
52
50
53
private func edit( list: CustomList ) {
51
- // Remove previous edit coordinator to prevent accumulation.
52
- childCoordinators. filter { $0 is EditCustomListCoordinator } . forEach { $0. removeFromParent ( ) }
53
-
54
54
let coordinator = EditCustomListCoordinator (
55
55
navigationController: navigationController,
56
56
customListInteractor: interactor,
57
57
customList: list,
58
58
nodes: nodes
59
59
)
60
60
61
- coordinator. didFinish = { action, list in
62
- self . popToList ( )
63
- coordinator. removeFromParent ( )
61
+ coordinator. didFinish = { [ weak self] editCustomListCoordinator, action, list in
62
+ guard let self else { return }
63
+ popToList ( )
64
+ editCustomListCoordinator. removeFromParent ( )
64
65
65
66
self . updateRelayConstraints ( for: action, in: list)
66
67
self . listViewController. updateDataSource ( reloadExisting: action == . save)
@@ -90,8 +91,8 @@ class ListCustomListCoordinator: Coordinator, Presentable, Presenting {
90
91
relayConstraints. locations = . only( UserSelectedRelays ( locations: [ ] ) )
91
92
}
92
93
93
- tunnelManager. updateSettings ( [ . relayConstraints( relayConstraints) ] ) {
94
- self . tunnelManager. startTunnel ( )
94
+ tunnelManager. updateSettings ( [ . relayConstraints( relayConstraints) ] ) { [ weak self ] in
95
+ self ? . tunnelManager. startTunnel ( )
95
96
}
96
97
}
97
98
0 commit comments