notification: wait for cloning conversation

https://git.jami.net/savoirfairelinux/jami-daemon/-/issues/776
Change-Id: Ia314c1a9cc7cbac2fc349916e3bb31a96068e590
diff --git a/Ring/jamiNotificationExtension/NotificationService.swift b/Ring/jamiNotificationExtension/NotificationService.swift
index c751d0a..92855e9 100644
--- a/Ring/jamiNotificationExtension/NotificationService.swift
+++ b/Ring/jamiNotificationExtension/NotificationService.swift
@@ -61,6 +61,7 @@
     var numberOfFiles = 0 /// number of files need to be downloaded
     var numberOfMessages = 0 /// number of scheduled messages
     var syncCompleted = false
+    var waitForCloning = false
     private let tasksGroup = DispatchGroup()
     var accountId = ""
     let thumbnailSize = 100
@@ -143,6 +144,10 @@
                         return
                     case .gitMessage:
                         self.handleGitMessage()
+                    case .clone:
+                        // Should start daemon and wait until clone completed
+                        self.waitForCloning = true
+                        self.handleGitMessage()
                     case .unknown:
                         break
                     }
@@ -199,6 +204,9 @@
                                                   accountId: self.accountId,
                                                   conversationId: eventData.conversationId,
                                                   groupTitle: eventData.groupTitle)
+            case .conversationCloned:
+                self.waitForCloning = false
+                self.verifyTasksStatus()
             }
         }
     }
@@ -212,7 +220,7 @@
         /// We could finish in two cases:
         /// 1. we did not start account we are not waiting for the signals from the daemon
         /// 2. conversation synchronization completed and all files downloaded
-        if !self.accountIsActive || (self.syncCompleted && self.numberOfFiles == 0 && self.numberOfMessages == 0) {
+        if !self.accountIsActive || (self.syncCompleted && self.numberOfFiles == 0 && self.numberOfMessages == 0 && !self.waitForCloning) {
             self.tasksCompleted = true
             self.tasksGroup.leave()
         }