diff --git a/Sources/uYouPlusSettings.xm b/Sources/uYouPlusSettings.xm index 04e13e5..4d43383 100644 --- a/Sources/uYouPlusSettings.xm +++ b/Sources/uYouPlusSettings.xm @@ -330,6 +330,27 @@ extern NSBundle *uYouPlusBundle(); ]; [sectionItems addObject:appIcon]; + YTSettingsSectionItem *clearCache = [%c(YTSettingsSectionItem) + itemWithTitle:"Clear Cache" + titleDescription:nil + accessibilityIdentifier:nil + detailTextBlock:^NSString *() { + return GetCacheSize(); + } + selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + NSString *cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject; + [[NSFileManager defaultManager] removeItemAtPath:cachePath error:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + [cell setDetailText:GetCacheSize()]; + [[%c(YTToastResponderEvent) eventWithMessage:LOC(@"Done") firstResponder:[self parentResponder]] send]; + }); + }); + return YES; + } + ]; + [sectionItems addObject:clearCache]; + [%c(YTSettingsSectionItem) itemWithTitle:@"Clear Cache" titleDescription:nil accessibilityIdentifier:nil detailTextBlock:^NSString *() { return GetCacheSize(); } selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;