Marino Faggiana 7 жил өмнө
parent
commit
11f7c6f214

+ 22 - 15
iOSClient/Database/NCManageDatabase.swift

@@ -487,25 +487,32 @@ class NCManageDatabase: NSObject {
 
         let realm = try! Realm()
         
-        do {
-            try realm.write {
+        if realm.isInWriteTransaction {
+        
+            print("[LOG] Could not write to database, addActivityClient is already in write transaction")
+            
+        } else {
+            
+            do {
+                try realm.write {
                 
-                // Add new Activity
-                let addActivity = tableActivity()
+                    // Add new Activity
+                    let addActivity = tableActivity()
                 
-                addActivity.account = tableAccount.account
-                addActivity.action = action
-                addActivity.file = file
-                addActivity.fileID = fileID
-                addActivity.note = noteReplacing
-                addActivity.selector = selector
-                addActivity.type = type
-                addActivity.verbose = verbose
+                    addActivity.account = tableAccount.account
+                    addActivity.action = action
+                    addActivity.file = file
+                    addActivity.fileID = fileID
+                    addActivity.note = noteReplacing
+                    addActivity.selector = selector
+                    addActivity.type = type
+                    addActivity.verbose = verbose
                 
-                realm.add(addActivity)
+                    realm.add(addActivity)
+                }
+            } catch let error {
+                print("[LOG] Could not write to database: ", error)
             }
-        } catch let error {
-            print("[LOG] Could not write to database: ", error)
         }
     }
     

+ 22 - 18
iOSClient/Settings/CCSettings.m

@@ -482,29 +482,33 @@
 
 - (void)sendMail:(XLFormRowDescriptor *)sender
 {
-    // Email Subject
-    NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
-    // Email Content
-    NSString *messageBody;
-    // Email Recipents
-    NSArray *toRecipents;
-    
-    messageBody = [NSString stringWithFormat:@"\n\n\n%@ Version %@ (%@)", [NCBrandOptions sharedInstance].brand, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
-    toRecipents = [NSArray arrayWithObject:[NCBrandOptions sharedInstance].mailMe];
-    
-    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
-    mc.mailComposeDelegate = self;
-    [mc setSubject:emailTitle];
-    [mc setMessageBody:messageBody isHTML:NO];
-    [mc setToRecipients:toRecipents];
-    
-    // Present mail view controller on screen
+    if ([MFMailComposeViewController canSendMail]) {
+
+        // Email Subject
+        NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
+        // Email Content
+        NSString *messageBody;
+        // Email Recipents
+        NSArray *toRecipents;
+    
+        messageBody = [NSString stringWithFormat:@"\n\n\n%@ Version %@ (%@)", [NCBrandOptions sharedInstance].brand, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
+        toRecipents = [NSArray arrayWithObject:[NCBrandOptions sharedInstance].mailMe];
+    
+        MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
+        mc.mailComposeDelegate = self;
+        [mc setSubject:emailTitle];
+        [mc setMessageBody:messageBody isHTML:NO];
+        [mc setToRecipients:toRecipents];
+    
+        // Present mail view controller on screen
     [self presentViewController:mc animated:YES completion:NULL];
+    }
 }
 
 - (void)sendMailEncryptPass
 {
-    [CCUtility sendMailEncryptPass:[CCUtility getEmail] validateEmail:NO form:self nameImage:@"backgroundDetail"];
+    if ([MFMailComposeViewController canSendMail])
+        [CCUtility sendMailEncryptPass:[CCUtility getEmail] validateEmail:NO form:self nameImage:@"backgroundDetail"];
 }
 
 #pragma --------------------------------------------------------------------------------------------