marinofaggiana 4 jaren geleden
bovenliggende
commit
01f3ff3a50

+ 1 - 1
iOSClient/AppDelegate.m

@@ -268,7 +268,7 @@
     // Not Photos Video in library ? then align and Init Auto Upload
     NSArray *recordsPhotoLibrary = [[NCManageDatabase shared] getPhotoLibraryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", self.account]];
     if ([recordsPhotoLibrary count] == 0) {
-        [[NCAutoUpload shared] alignPhotoLibrary];
+        [[NCAutoUpload shared] alignPhotoLibraryWithViewController:nil];
     }
     
     // Start Auto Upload

+ 4 - 4
iOSClient/Networking/NCAutoUpload.swift

@@ -126,9 +126,9 @@ class NCAutoUpload: NSObject, CLLocationManagerDelegate {
     
     // MARK: -
 
-    @objc func alignPhotoLibrary() {
+    @objc func alignPhotoLibrary(viewController: UIViewController?) {
         if let account = NCManageDatabase.shared.getAccountActive() {
-            getCameraRollAssets(account: account, selector: NCBrandGlobal.shared.selectorUploadAutoUploadAll, alignPhotoLibrary: true) { (assets) in
+            getCameraRollAssets(viewController: viewController, account: account, selector: NCBrandGlobal.shared.selectorUploadAutoUploadAll, alignPhotoLibrary: true) { (assets) in
                 NCManageDatabase.shared.clearTable(tablePhotoLibrary.self, account: account.account)
                 if let assets = assets {
                     NCManageDatabase.shared.addPhotoLibrary(assets, account: account.account)
@@ -138,9 +138,9 @@ class NCAutoUpload: NSObject, CLLocationManagerDelegate {
         }
     }
     
-    private func getCameraRollAssets(account: tableAccount, selector: String, alignPhotoLibrary: Bool, completion: @escaping (_ assets: [PHAsset]?)->()) {
+    private func getCameraRollAssets(viewController: UIViewController?, account: tableAccount, selector: String, alignPhotoLibrary: Bool, completion: @escaping (_ assets: [PHAsset]?)->()) {
                 
-        NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: appDelegate.window.rootViewController) { (hasPermission) in
+        NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: viewController) { (hasPermission) in
             if hasPermission {
                 let assetCollection = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.smartAlbum, subtype: PHAssetCollectionSubtype.smartAlbumUserLibrary, options: nil)
                 if assetCollection.count > 0 {

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -353,7 +353,7 @@
     
     [CCUtility createDirectoryStandard];
 
-    [[NCAutoUpload shared] alignPhotoLibrary];
+    [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
 
     // Inizialized home
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCBrandGlobal.shared.notificationCenterInitializeMain object:nil userInfo:nil];

+ 3 - 3
iOSClient/Settings/CCManageAutoUpload.m

@@ -259,7 +259,7 @@
                 [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadVideo" state:YES];
             }
             
-            [[NCAutoUpload shared] alignPhotoLibrary];
+            [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
             
         } else {
             
@@ -326,7 +326,7 @@
         [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadImage" state:[[rowDescriptor.value valueData] boolValue]];
 
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            [[NCAutoUpload shared] alignPhotoLibrary];
+            [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
         }
     }
     
@@ -340,7 +340,7 @@
         [[NCManageDatabase shared] setAccountAutoUploadProperty:@"autoUploadVideo" state:[[rowDescriptor.value valueData] boolValue]];
 
         if ([[rowDescriptor.value valueData] boolValue] == YES){
-            [[NCAutoUpload shared] alignPhotoLibrary];
+            [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
         }
     }