Эх сурвалжийг харах

Add dateSearchContentTypeImageVideo on DB

Marino Faggiana 7 жил өмнө
parent
commit
f2d26631ae

+ 1 - 0
iOSClient/Database/NCDatabase.swift

@@ -38,6 +38,7 @@ class tableAccount: Object {
     @objc dynamic var autoUploadVideo: Bool = false
     @objc dynamic var autoUploadWWAnPhoto: Bool = false
     @objc dynamic var autoUploadWWAnVideo: Bool = false
+    @objc dynamic var dateSearchContentTypeImageVideo = NSDate.distantPast
     @objc dynamic var displayName = ""
     @objc dynamic var email = ""
     @objc dynamic var enabled: Bool = false

+ 25 - 2
iOSClient/Database/NCManageDatabase.swift

@@ -57,7 +57,7 @@ class NCManageDatabase: NSObject {
         let config = Realm.Configuration(
         
             fileURL: dirGroup?.appendingPathComponent("\(appDatabaseNextcloud)/\(k_databaseDefault)"),
-            schemaVersion: 17,
+            schemaVersion: 18,
             
             // 10 : Version 2.18.0
             // 11 : Version 2.18.2
@@ -67,6 +67,7 @@ class NCManageDatabase: NSObject {
             // 15 : Version 2.19.2
             // 16 : Version 2.20.2
             // 17 : Version 2.20.4
+            // 18 : Version 2.20.6
             
             migrationBlock: { migration, oldSchemaVersion in
                 // We haven’t migrated anything yet, so oldSchemaVersion == 0
@@ -405,7 +406,7 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func setAccountsUserProfile(_ userProfile: OCUserProfile) -> tableAccount? {
+    @objc func setAccountUserProfile(_ userProfile: OCUserProfile) -> tableAccount? {
      
         guard let activeAccount = self.getAccountActive() else {
             return nil
@@ -448,6 +449,28 @@ class NCManageDatabase: NSObject {
         return activeAccount
     }
     
+    @objc func setAccountDateSearchContentTypeImageVideo(_ date: Date) {
+        
+        guard let activeAccount = self.getAccountActive() else {
+            return
+        }
+        
+        let realm = try! Realm()
+        
+        do {
+            try realm.write {
+                
+                guard let result = realm.objects(tableAccount.self).filter("account = %@", activeAccount.account).first else {
+                    return
+                }
+                
+                result.dateSearchContentTypeImageVideo = date
+            }
+        } catch let error {
+            print("[LOG] Could not write to database: ", error)
+        }
+    }
+    
     //MARK: -
     //MARK: Table Activity
 

+ 1 - 1
iOSClient/Login/CCLogin.m

@@ -471,7 +471,7 @@
     if (account) {
     
         // Update User (+ userProfile.id)
-        (void)[[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
+        (void)[[NCManageDatabase sharedInstance] setAccountUserProfile:userProfile];
         
         // Set this account as default
         tableAccount *account = [[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];

+ 1 - 1
iOSClient/Main/CCMain.m

@@ -1128,7 +1128,7 @@
         return;
     
     // Update User (+ userProfile.id) & active account & account network
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountUserProfile:userProfile];
     if (tableAccount) {
         [[CCNetworking sharedNetworking] settingAccount];
         [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:tableAccount.password];

+ 6 - 0
iOSClient/Photos/CCPhotos.m

@@ -549,6 +549,9 @@
         return;
     }
     
+    // Update date 
+    [[NCManageDatabase sharedInstance] setAccountDateSearchContentTypeImageVideo:[NSDate date]];
+    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
         
         NSMutableArray *addMetadatas = [NSMutableArray new];
@@ -579,6 +582,9 @@
     if (appDelegate.activeAccount.length == 0 || _isSearchMode)
         return;
     
+    //tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
+    // account.dateSearchContentTypeImageVideo
+    
     [[CCActions sharedInstance] search:@"" fileName:@"" depth:@"infinity" date:[NSDate distantPast] contenType:@[@"image/%", @"video/%"] selector:selectorSearchContentType delegate:self];
     
     _isSearchMode = YES;