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

Merge branch 'fix-unauth-crash-invitation' into 'development'

Fixes issue w/ unauth users were deeplinking

See merge request elixxir/client-ios!60
parents e4cafeff c4d7ae96
No related branches found
No related tags found
3 merge requests!71Releasing v1.1.5 (214),!67v1.1.5 b(203),!60Fixes issue w/ unauth users were deeplinking
Showing
with 53 additions and 53 deletions
......@@ -20,7 +20,6 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
@Dependency private var crashReporter: CrashReporter
@Dependency private var dropboxService: DropboxInterface
@KeyObject(.invitation, defaultValue: nil) var invitation: String?
@KeyObject(.hideAppList, defaultValue: false) var hideAppList: Bool
@KeyObject(.recordingLogs, defaultValue: true) var recordingLogs: Bool
@KeyObject(.crashReporting, defaultValue: true) var isCrashReportingEnabled: Bool
......@@ -145,9 +144,7 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
) -> Bool {
if let username = getUsernameFromInvitationDeepLink(url) {
let router = try! DependencyInjection.Container.shared.resolve() as PushRouter
invitation = username
router.navigateTo(.search, {})
router.navigateTo(.search(username: username), {})
return true
} else {
return dropboxService.handleOpenUrl(url)
......
......@@ -15,17 +15,18 @@ extension PushRouter {
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 .search(username: let username):
if let _ = try? DependencyInjection.Container.shared.resolve() as SessionType,
!(navigationController.viewControllers.last is SearchContainerController) {
navigationController.setViewControllers([
ChatListController(),
SearchContainerController(username)
], 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 {
......
......@@ -27,7 +27,7 @@ public struct ChatListCoordinator: ChatListCoordinating {
var bottomPresenter: Presenting = BottomPresenter()
var scanFactory: () -> UIViewController
var searchFactory: () -> UIViewController
var searchFactory: (String?) -> UIViewController
var newGroupFactory: () -> UIViewController
var contactsFactory: () -> UIViewController
var contactFactory: (Contact) -> UIViewController
......@@ -37,7 +37,7 @@ public struct ChatListCoordinator: ChatListCoordinating {
public init(
scanFactory: @escaping () -> UIViewController,
searchFactory: @escaping () -> UIViewController,
searchFactory: @escaping (String?) -> UIViewController,
newGroupFactory: @escaping () -> UIViewController,
contactsFactory: @escaping () -> UIViewController,
contactFactory: @escaping (Contact) -> UIViewController,
......@@ -58,7 +58,7 @@ public struct ChatListCoordinator: ChatListCoordinating {
public extension ChatListCoordinator {
func toSearch(from parent: UIViewController) {
let screen = searchFactory()
let screen = searchFactory(nil)
pushPresenter.present(screen, from: parent)
}
......
......@@ -28,7 +28,7 @@ public struct ContactListCoordinator: ContactListCoordinating {
var replacePresenter: Presenting = ReplacePresenter(mode: .replaceLast)
var scanFactory: () -> UIViewController
var searchFactory: () -> UIViewController
var searchFactory: (String?) -> UIViewController
var newGroupFactory: () -> UIViewController
var requestsFactory: () -> UIViewController
var contactFactory: (Contact) -> UIViewController
......@@ -39,7 +39,7 @@ public struct ContactListCoordinator: ContactListCoordinating {
public init(
scanFactory: @escaping () -> UIViewController,
searchFactory: @escaping () -> UIViewController,
searchFactory: @escaping (String?) -> UIViewController,
newGroupFactory: @escaping () -> UIViewController,
requestsFactory: @escaping () -> UIViewController,
contactFactory: @escaping (Contact) -> UIViewController,
......@@ -84,7 +84,7 @@ public extension ContactListCoordinator {
}
func toSearch(from parent: UIViewController) {
let screen = searchFactory()
let screen = searchFactory(nil)
pushPresenter.present(screen, from: parent)
}
......
......@@ -21,7 +21,6 @@ public enum Key: String {
// MARK: General
case theme
case invitation
// MARK: Requests
......
......@@ -49,17 +49,15 @@ public final class LaunchController: UIViewController {
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
switch $0 {
case .search:
coordinator.toSearch(from: self)
case .chats:
if let pushRoute = pendingPushRoute {
switch pushRoute {
case .search:
coordinator.toSearch(from: self)
case .requests:
coordinator.toRequests(from: self)
case .search(username: let username):
coordinator.toSearch(searching: username, from: self)
case .groupChat(id: let groupId):
if let groupInfo = viewModel.getGroupInfoWith(groupId: groupId) {
coordinator.toGroupChat(with: groupInfo, from: self)
......
......@@ -5,8 +5,8 @@ import Presentation
public protocol LaunchCoordinating {
func toChats(from: UIViewController)
func toSearch(from: UIViewController)
func toRequests(from: UIViewController)
func toSearch(searching: String, from: UIViewController)
func toOnboarding(with: String, from: UIViewController)
func toSingleChat(with: Contact, from: UIViewController)
func toGroupChat(with: GroupInfo, from: UIViewController)
......@@ -15,7 +15,7 @@ public protocol LaunchCoordinating {
public struct LaunchCoordinator: LaunchCoordinating {
var replacePresenter: Presenting = ReplacePresenter()
var searchFactory: () -> UIViewController
var searchFactory: (String) -> UIViewController
var requestsFactory: () -> UIViewController
var chatListFactory: () -> UIViewController
var onboardingFactory: (String) -> UIViewController
......@@ -23,7 +23,7 @@ public struct LaunchCoordinator: LaunchCoordinating {
var groupChatFactory: (GroupInfo) -> UIViewController
public init(
searchFactory: @escaping () -> UIViewController,
searchFactory: @escaping (String) -> UIViewController,
requestsFactory: @escaping () -> UIViewController,
chatListFactory: @escaping () -> UIViewController,
onboardingFactory: @escaping (String) -> UIViewController,
......@@ -40,8 +40,8 @@ public struct LaunchCoordinator: LaunchCoordinating {
}
public extension LaunchCoordinator {
func toSearch(from parent: UIViewController) {
let screen = searchFactory()
func toSearch(searching: String, from parent: UIViewController) {
let screen = searchFactory(searching)
let chatListScreen = chatListFactory()
replacePresenter.present(chatListScreen, screen, from: parent)
}
......
......@@ -24,7 +24,6 @@ struct Update {
enum LaunchRoute {
case chats
case search
case update(Update)
case onboarding(String)
}
......@@ -37,7 +36,6 @@ final class LaunchViewModel {
@Dependency private var permissionHandler: PermissionHandling
@KeyObject(.username, defaultValue: nil) var username: String?
@KeyObject(.invitation, defaultValue: nil) var invitation: String?
@KeyObject(.biometrics, defaultValue: false) var isBiometricsOn: Bool
var hudPublisher: AnyPublisher<HUDStatus, Never> {
......@@ -187,23 +185,14 @@ final class LaunchViewModel {
switch $0 {
case .success(let granted):
guard granted else { return }
if self.invitation != nil {
self.routeSubject.send(.search)
} else {
self.routeSubject.send(.chats)
}
case .failure(let error):
self.hudSubject.send(.error(HUDError(with: error)))
}
}
} else {
if self.invitation != nil {
self.routeSubject.send(.search)
} else {
self.routeSubject.send(.chats)
}
}
}
}
......@@ -41,7 +41,7 @@ public struct OnboardingCoordinator: OnboardingCoordinating {
var emailFactory: () -> UIViewController
var phoneFactory: () -> UIViewController
var searchFactory: () -> UIViewController
var searchFactory: (String?) -> UIViewController
var welcomeFactory: () -> UIViewController
var chatListFactory: () -> UIViewController
var usernameFactory: (String) -> UIViewController
......@@ -54,7 +54,7 @@ public struct OnboardingCoordinator: OnboardingCoordinating {
public init(
emailFactory: @escaping () -> UIViewController,
phoneFactory: @escaping () -> UIViewController,
searchFactory: @escaping () -> UIViewController,
searchFactory: @escaping (String?) -> UIViewController,
welcomeFactory: @escaping () -> UIViewController,
chatListFactory: @escaping () -> UIViewController,
usernameFactory: @escaping (String) -> UIViewController,
......@@ -114,7 +114,7 @@ public extension OnboardingCoordinator {
}
func toChats(from parent: UIViewController) {
let searchScreen = searchFactory()
let searchScreen = searchFactory(nil)
let chatListScreen = chatListFactory()
replacePresenter.present(chatListScreen, searchScreen, from: parent)
}
......
......@@ -4,10 +4,10 @@ public struct PushRouter {
public typealias NavigateTo = (Route, @escaping () -> Void) -> Void
public enum Route {
case search
case requests
case groupChat(id: Data)
case contactChat(id: Data)
case search(username: String)
}
public var navigateTo: NavigateTo
......
......@@ -24,7 +24,7 @@ public struct RequestsCoordinator: RequestsCoordinating {
var bottomPresenter: Presenting = BottomPresenter()
var fullscreenPresenter: Presenting = FullscreenPresenter()
var searchFactory: () -> UIViewController
var searchFactory: (String?) -> UIViewController
var contactFactory: (Contact) -> UIViewController
var singleChatFactory: (Contact) -> UIViewController
var groupChatFactory: (GroupInfo) -> UIViewController
......@@ -32,7 +32,7 @@ public struct RequestsCoordinator: RequestsCoordinating {
var nicknameFactory: (String, @escaping StringClosure) -> UIViewController
public init(
searchFactory: @escaping () -> UIViewController,
searchFactory: @escaping (String?) -> UIViewController,
contactFactory: @escaping (Contact) -> UIViewController,
singleChatFactory: @escaping (Contact) -> UIViewController,
groupChatFactory: @escaping (GroupInfo) -> UIViewController,
......@@ -81,7 +81,7 @@ public extension RequestsCoordinator {
}
func toSearch(from parent: UIViewController) {
let screen = searchFactory()
let screen = searchFactory(nil)
pushPresenter.present(screen, from: parent)
}
......
......@@ -14,11 +14,18 @@ public final class SearchContainerController: UIViewController {
private var contentOffset: CGPoint?
private var cancellables = Set<AnyCancellable>()
private let leftController: SearchLeftController
private let viewModel = SearchContainerViewModel()
private let leftController = SearchLeftController()
private let rightController = SearchRightController()
private var drawerCancellables = Set<AnyCancellable>()
public init(_ invitation: String? = nil) {
self.leftController = .init(invitation)
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { nil }
public override func loadView() {
view = screenView
embedControllers()
......
......@@ -19,14 +19,21 @@ final class SearchLeftController: UIViewController {
lazy private var screenView = SearchLeftView()
let viewModel: SearchLeftViewModel
private var dataSource: SearchDiffableDataSource!
private(set) var viewModel = SearchLeftViewModel()
private var drawerCancellables = Set<AnyCancellable>()
private let adrpURLString = "https://links.xx.network/adrp"
private var cancellables = Set<AnyCancellable>()
private var hudCancellables = Set<AnyCancellable>()
init(_ invitation: String? = nil) {
self.viewModel = .init(invitation)
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { nil }
override func loadView() {
view = screenView
}
......
......@@ -3,7 +3,6 @@ import UIKit
import Shared
import Combine
import XXModels
import Defaults
import Countries
import Integration
import NetworkMonitor
......@@ -22,8 +21,6 @@ final class SearchLeftViewModel {
@Dependency var session: SessionType
@Dependency var networkMonitor: NetworkMonitoring
@KeyObject(.invitation, defaultValue: nil) var invitation: String?
var hudPublisher: AnyPublisher<HUDStatus, Never> {
hudSubject.eraseToAnyPublisher()
}
......@@ -36,12 +33,17 @@ final class SearchLeftViewModel {
stateSubject.eraseToAnyPublisher()
}
private var invitation: String?
private var searchCancellables = Set<AnyCancellable>()
private let successSubject = PassthroughSubject<Contact, Never>()
private let hudSubject = CurrentValueSubject<HUDStatus, Never>(.none)
private let stateSubject = CurrentValueSubject<SearchLeftViewState, Never>(.init())
private var networkCancellable = Set<AnyCancellable>()
init(_ invitation: String? = nil) {
self.invitation = invitation
}
func viewDidAppear() {
if let pendingInvitation = invitation {
invitation = nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment