Skip to content

Commit a935f54

Browse files
committed
SAO-2564: Takedown notification does not redirect to the parent folder - wrong navigation
1 parent 4e40f3d commit a935f54

File tree

1 file changed

+49
-25
lines changed

1 file changed

+49
-25
lines changed

iMEGA/My Account/Notifications/ViewModel/NotificationsViewRouter.swift

+49-25
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ struct NotificationsViewRouter: NotificationsViewRouting {
7373
nodeHierarchy: nodeHierarchy,
7474
isInRubbishBin: isInRubbishBin
7575
)
76-
77-
cancelRootSearchIfNeeded(in: navigationController)
7876
}
7977

8078
private func selectTabController(in mainTBC: MainTabBarController, isOwnNode: Bool) {
@@ -98,31 +96,57 @@ struct NotificationsViewRouter: NotificationsViewRouting {
9896
nodeHierarchy: [NodeEntity],
9997
isInRubbishBin: Bool
10098
) {
101-
Task { @MainActor in
102-
let factory = CloudDriveViewControllerFactory.make(nc: navigationController)
103-
104-
nodeHierarchy.dropLast().forEach { node in
105-
guard let intermediateVC = factory.buildBare(
106-
parentNode: node,
107-
config: .init(displayMode: .cloudDrive)
108-
) else {
109-
return
110-
}
111-
navigationController.addChild(intermediateVC)
112-
}
113-
114-
if let lastNode = nodeHierarchy.last {
115-
let displayMode: DisplayMode = isInRubbishBin ? .rubbishBin : .cloudDrive
116-
guard let lastVC = factory.buildBare(
117-
parentNode: lastNode,
118-
config: .init(displayMode: displayMode)
119-
) else {
120-
return
121-
}
122-
123-
navigationController.pushViewController(lastVC, animated: false)
99+
let factory = CloudDriveViewControllerFactory.make(nc: navigationController)
100+
101+
pushIntermediateNodes(
102+
in: navigationController,
103+
using: factory,
104+
nodeHierarchy: nodeHierarchy.dropLast()
105+
)
106+
107+
pushCloudDriveViewController(
108+
nodeHierarchy.last,
109+
in: navigationController,
110+
using: factory,
111+
isInRubbishBin: isInRubbishBin
112+
)
113+
114+
cancelRootSearchIfNeeded(in: navigationController)
115+
}
116+
117+
private func pushIntermediateNodes(
118+
in navigationController: UINavigationController,
119+
using factory: CloudDriveViewControllerFactory,
120+
nodeHierarchy: [NodeEntity]
121+
) {
122+
nodeHierarchy.forEach { node in
123+
guard let intermediateVC = factory.buildBare(
124+
parentNode: node,
125+
config: .init(displayMode: .cloudDrive)
126+
) else {
127+
return
124128
}
129+
intermediateVC.navigationItem.backButtonTitle = ""
130+
navigationController.addChild(intermediateVC)
131+
}
132+
}
133+
134+
private func pushCloudDriveViewController(
135+
_ node: NodeEntity?,
136+
in navigationController: UINavigationController,
137+
using factory: CloudDriveViewControllerFactory,
138+
isInRubbishBin: Bool
139+
) {
140+
let displayMode: DisplayMode = isInRubbishBin ? .rubbishBin : .cloudDrive
141+
142+
guard let node, let lastVC = factory.buildBare(
143+
parentNode: node,
144+
config: .init(displayMode: displayMode)
145+
) else {
146+
return
125147
}
148+
lastVC.navigationItem.backButtonTitle = ""
149+
navigationController.pushViewController(lastVC, animated: false)
126150
}
127151

128152
private func resetCurrentNavigationController() {

0 commit comments

Comments
 (0)