Skip to content
Snippets Groups Projects
Commit 6b7ccd2d authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Fixed comments on MR

parent ff3d9098
No related branches found
No related tags found
3 merge requests!71Releasing v1.1.5 (214),!67v1.1.5 b(203),!59Invite friends
...@@ -143,8 +143,8 @@ public class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -143,8 +143,8 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
open url: URL, open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:] options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool { ) -> Bool {
if let username = getUsernameFromInvitationDeepLink(url), if let username = getUsernameFromInvitationDeepLink(url) {
let router = try? DependencyInjection.Container.shared.resolve() as PushRouter { let router = try! DependencyInjection.Container.shared.resolve() as PushRouter
invitation = username invitation = username
router.navigateTo(.search, {}) router.navigateTo(.search, {})
......
...@@ -251,46 +251,3 @@ struct DependencyRegistrator { ...@@ -251,46 +251,3 @@ struct DependencyRegistrator {
) as ChatListCoordinating) ) as ChatListCoordinating)
} }
} }
extension PushRouter {
static func live(navigationController: UINavigationController) -> PushRouter {
PushRouter { route, completion in
if let launchController = navigationController.viewControllers.last as? LaunchController {
launchController.pendingPushRoute = route
} else {
switch route {
case .search:
if (navigationController.viewControllers.last as? SearchContainerController) == nil {
navigationController.setViewControllers([
ChatListController(),
SearchContainerController()
], animated: true)
}
case .requests:
if (navigationController.viewControllers.last as? RequestsContainerController) == nil {
navigationController.setViewControllers([RequestsContainerController()], animated: true)
}
case .contactChat(id: let id):
if let session = try? DependencyInjection.Container.shared.resolve() as SessionType,
let contact = try? session.dbManager.fetchContacts(.init(id: [id])).first {
navigationController.setViewControllers([
ChatListController(),
SingleChatController(contact)
], animated: true)
}
case .groupChat(id: let id):
if let session = try? DependencyInjection.Container.shared.resolve() as SessionType,
let info = try? session.dbManager.fetchGroupInfos(.init(groupId: id)).first {
navigationController.setViewControllers([
ChatListController(),
GroupChatController(info)
], animated: true)
}
}
}
completion()
}
}
}
import UIKit
import PushFeature
import Integration
import ChatFeature
import SearchFeature
import LaunchFeature
import ChatListFeature
import RequestsFeature
import DependencyInjection
extension PushRouter {
static func live(navigationController: UINavigationController) -> PushRouter {
PushRouter { route, completion in
if let launchController = navigationController.viewControllers.last as? LaunchController {
launchController.pendingPushRoute = route
} else {
switch route {
case .search:
if !(navigationController.viewControllers.last is SearchContainerController) {
navigationController.setViewControllers([
ChatListController(),
SearchContainerController()
], animated: true)
}
case .requests:
if !(navigationController.viewControllers.last is RequestsContainerController) {
navigationController.setViewControllers([RequestsContainerController()], animated: true)
}
case .contactChat(id: let id):
if let session = try? DependencyInjection.Container.shared.resolve() as SessionType,
let contact = try? session.dbManager.fetchContacts(.init(id: [id])).first {
navigationController.setViewControllers([
ChatListController(),
SingleChatController(contact)
], animated: true)
}
case .groupChat(id: let id):
if let session = try? DependencyInjection.Container.shared.resolve() as SessionType,
let info = try? session.dbManager.fetchGroupInfos(.init(groupId: id)).first {
navigationController.setViewControllers([
ChatListController(),
GroupChatController(info)
], animated: true)
}
}
}
completion()
}
}
}
...@@ -48,6 +48,8 @@ final class SearchLeftViewModel { ...@@ -48,6 +48,8 @@ final class SearchLeftViewModel {
stateSubject.value.input = pendingInvitation stateSubject.value.input = pendingInvitation
hudSubject.send(.onAction(Localized.Ud.Search.cancel)) hudSubject.send(.onAction(Localized.Ud.Search.cancel))
networkCancellable.removeAll()
networkMonitor.statusPublisher networkMonitor.statusPublisher
.first { $0 == .available } .first { $0 == .available }
.eraseToAnyPublisher() .eraseToAnyPublisher()
......
...@@ -4,18 +4,18 @@ import XCTest ...@@ -4,18 +4,18 @@ import XCTest
final class AppDelegateTests: XCTestCase { final class AppDelegateTests: XCTestCase {
func test_invitationDeeplink() { func test_invitationDeeplink() {
let host = "messenger" XCTAssertNil(
let query = "invitation" getUsernameFromInvitationDeepLink(URL(string: "http://messenger?invitation=john_doe")!)
let scheme = "xxnetwork" )
let username = "john_doe"
let url = URL(string: "\(scheme)://\(host)?\(query)=\(username)")! XCTAssertNotEqual(
XCTAssertEqual(getUsernameFromInvitationDeepLink(url), username) getUsernameFromInvitationDeepLink(URL(string: "xxnetwork://messenger?invitation=the_rock")!),
"john_doe"
)
let malformedURL = URL(string: "\(scheme)\(host)\(query)\(username)")! XCTAssertEqual(
XCTAssertNil(getUsernameFromInvitationDeepLink(malformedURL)) getUsernameFromInvitationDeepLink(URL(string: "xxnetwork://messenger?invitation=john_doe")!),
"john_doe"
let urlAnotherUsername = URL(string: "\(scheme)://\(host)?\(query)=asdfg")! )
XCTAssertNotEqual(getUsernameFromInvitationDeepLink(urlAnotherUsername), username)
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment