Bläddra i källkod

add internal clear all cache

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 år sedan
förälder
incheckning
24db01def0
1 ändrade filer med 23 tillägg och 5 borttagningar
  1. 23 5
      iOSClient/Settings/CCAdvanced.m

+ 23 - 5
iOSClient/Settings/CCAdvanced.m

@@ -267,7 +267,19 @@
     [row.cellConfig setObject:[[UIImage imageNamed:@"trash"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
     row.action.formSelector = @selector(clearCacheRequest:);
     [sectionSize addFormRow:row];
-    
+
+#ifdef DEBUG
+    // Clear all cache
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeraallcache" rowType:XLFormRowDescriptorTypeButton title:@"Clear all cache"];
+    row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
+    [row.cellConfig setObject:[UIColor blueColor] forKey:@"textLabel.textColor"];
+    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+    [row.cellConfig setObject:[[UIImage imageNamed:@"trash"] imageWithColor:[UIColor blueColor] size:25] forKey:@"imageView.image"];
+    row.action.formSelector = @selector(clearAllCacheRequest:);
+    [sectionSize addFormRow:row];
+#endif
+
     // Section EXIT --------------------------------------------------------
     
     section = [XLFormSectionDescriptor formSection];
@@ -377,16 +389,16 @@
 
 #pragma mark - Clear Cache
 
-- (void)clearCache
+- (void)clearCache:(NSString *)account
 {
-    [[NCNetworking shared] cancelAllTransferWithAccount:appDelegate.account completion:^{ }];
+    [[NCNetworking shared] cancelAllTransferWithAccount:account completion:^{ }];
     [[NCOperationQueue shared] cancelAllQueue];
     [[NCNetworking shared] cancelAllTask];
     
     [[NSURLCache sharedURLCache] setMemoryCapacity:0];
     [[NSURLCache sharedURLCache] setDiskCapacity:0];
     
-    [[NCManageDatabase shared] clearDatabaseWithAccount:appDelegate.account removeAccount:false];
+    [[NCManageDatabase shared] clearDatabaseWithAccount:account removeAccount:false];
     
     [CCUtility removeGroupDirectoryProviderStorage];
     [CCUtility removeGroupLibraryDirectory];
@@ -418,7 +430,7 @@
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
         [[NCActivityIndicator shared] startActivityWithBackgroundView:nil style: UIActivityIndicatorViewStyleLarge];
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-            [self clearCache];
+            [self clearCache:appDelegate.account];
         });
     }]];
     
@@ -433,6 +445,12 @@
     [self presentViewController:alertController animated:YES completion:nil];
 }
 
+- (void)clearAllCacheRequest:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    [self clearCache:nil];
+}
+
 - (void)calculateSize
 {
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{