From 21d1fe0aff56256802c4a6de51ee75f9fa3b84ba Mon Sep 17 00:00:00 2001
From: Bruno Muniz Azevedo Filho <bruno@elixxir.io>
Date: Thu, 28 Jul 2022 16:53:26 -0300
Subject: [PATCH] Working on deeplinking into search

---
 Sources/App/AppDelegate.swift                      | 14 +++++++++++++-
 Sources/LaunchFeature/LaunchController.swift       |  1 -
 .../Controllers/SearchLeftController.swift         |  1 -
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Sources/App/AppDelegate.swift b/Sources/App/AppDelegate.swift
index 72a7f682..f2ba599d 100644
--- a/Sources/App/AppDelegate.swift
+++ b/Sources/App/AppDelegate.swift
@@ -24,6 +24,7 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
     @KeyObject(.recordingLogs, defaultValue: true) var recordingLogs: Bool
     @KeyObject(.crashReporting, defaultValue: true) var isCrashReportingEnabled: Bool
 
+    var invitation: String?
     var calledStopNetwork = false
     var forceFailedPendingMessages = false
 
@@ -133,6 +134,12 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
     }
 
     public func applicationDidBecomeActive(_ application: UIApplication) {
+        // TODO:
+        /// If an invitation is set -> navigate to
+        /// search screen and perform a search
+        ///
+        invitation = nil
+
         application.applicationIconBadgeNumber = 0
         coverView?.removeFromSuperview()
     }
@@ -142,7 +149,12 @@ public class AppDelegate: UIResponder, UIApplicationDelegate {
         open url: URL,
         options: [UIApplication.OpenURLOptionsKey : Any] = [:]
     ) -> Bool {
-        dropboxService.handleOpenUrl(url)
+        if let host = url.host, host.starts(with: "invitation-") {
+            invitation = host.replacingOccurrences(of: "invitation-", with: "")
+            return true
+        }
+
+        return dropboxService.handleOpenUrl(url)
     }
 }
 
diff --git a/Sources/LaunchFeature/LaunchController.swift b/Sources/LaunchFeature/LaunchController.swift
index 2eb373f5..8db4bd63 100644
--- a/Sources/LaunchFeature/LaunchController.swift
+++ b/Sources/LaunchFeature/LaunchController.swift
@@ -5,7 +5,6 @@ import Combine
 import PushFeature
 import DependencyInjection
 
-
 public final class LaunchController: UIViewController {
     @Dependency private var hud: HUD
     @Dependency private var coordinator: LaunchCoordinating
diff --git a/Sources/SearchFeature/Controllers/SearchLeftController.swift b/Sources/SearchFeature/Controllers/SearchLeftController.swift
index bbfabd28..6be71bfe 100644
--- a/Sources/SearchFeature/Controllers/SearchLeftController.swift
+++ b/Sources/SearchFeature/Controllers/SearchLeftController.swift
@@ -403,7 +403,6 @@ final class SearchLeftController: UIViewController {
 
         coordinator.toDrawer(drawer, from: self)
     }
-
 }
 
 extension SearchLeftController: UITableViewDelegate {
-- 
GitLab