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 {
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
if let username = getUsernameFromInvitationDeepLink(url),
let router = try? DependencyInjection.Container.shared.resolve() as PushRouter {
if let username = getUsernameFromInvitationDeepLink(url) {
let router = try! DependencyInjection.Container.shared.resolve() as PushRouter
invitation = username
router.navigateTo(.search, {})
......
......@@ -251,46 +251,3 @@ struct DependencyRegistrator {
) 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 {
stateSubject.value.input = pendingInvitation
hudSubject.send(.onAction(Localized.Ud.Search.cancel))
networkCancellable.removeAll()
networkMonitor.statusPublisher
.first { $0 == .available }
.eraseToAnyPublisher()
......
......@@ -4,18 +4,18 @@ import XCTest
final class AppDelegateTests: XCTestCase {
func test_invitationDeeplink() {
let host = "messenger"
let query = "invitation"
let scheme = "xxnetwork"
let username = "john_doe"
XCTAssertNil(
getUsernameFromInvitationDeepLink(URL(string: "http://messenger?invitation=john_doe")!)
)
let url = URL(string: "\(scheme)://\(host)?\(query)=\(username)")!
XCTAssertEqual(getUsernameFromInvitationDeepLink(url), username)
XCTAssertNotEqual(
getUsernameFromInvitationDeepLink(URL(string: "xxnetwork://messenger?invitation=the_rock")!),
"john_doe"
)
let malformedURL = URL(string: "\(scheme)\(host)\(query)\(username)")!
XCTAssertNil(getUsernameFromInvitationDeepLink(malformedURL))
let urlAnotherUsername = URL(string: "\(scheme)://\(host)?\(query)=asdfg")!
XCTAssertNotEqual(getUsernameFromInvitationDeepLink(urlAnotherUsername), username)
XCTAssertEqual(
getUsernameFromInvitationDeepLink(URL(string: "xxnetwork://messenger?invitation=john_doe")!),
"john_doe"
)
}
}
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