Skip to content

Commit cc076e4

Browse files
authored
Merge pull request #2004 from nextcloud/fix/noid/avatar-cache
Improve avatar caching
2 parents 4dd3b1b + 151fc2a commit cc076e4

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

NextcloudTalk.xcodeproj/project.pbxproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4313,7 +4313,7 @@
43134313
repositoryURL = "https://github.com/SDWebImage/SDWebImage.git";
43144314
requirement = {
43154315
kind = exactVersion;
4316-
version = 5.15.7;
4316+
version = 5.20.1;
43174317
};
43184318
};
43194319
1F45A11F2A01D8BA005FE87D /* XCRemoteSwiftPackageReference "SDWebImageSVGKitPlugin" */ = {

NextcloudTalk/AppDelegate.m

+10-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#import <BackgroundTasks/BGTaskRequest.h>
1616
#import <BackgroundTasks/BGTask.h>
1717

18+
#import <SDWebImage/SDImageCache.h>
19+
1820
#import "NCAudioController.h"
1921
#import "NCAppBranding.h"
2022
#import "NCDatabaseManager.h"
@@ -67,15 +69,19 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
6769
NSLog(@"Configure App Settings");
6870
[NCSettingsController sharedInstance];
6971

70-
// Perform logfile cleanup only once in app lifecycle
71-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
72-
[NCUtils removeOldLogfiles];
72+
// Perform cleanup only once in app lifecycle
73+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void){
74+
@autoreleasepool {
75+
[NCUtils removeOldLogfiles];
76+
[[SDImageCache sharedImageCache].diskCache removeExpiredData];
77+
[[NCSettingsController sharedInstance] createAccountsFile];
78+
}
7379
});
7480

7581
UIDevice *currentDevice = [UIDevice currentDevice];
7682
[NCUtils log:[NSString stringWithFormat:@"Starting %@, version %@, %@ %@, model %@", NSBundle.mainBundle.bundleIdentifier, [NCAppBranding getAppVersionString], currentDevice.systemName, currentDevice.systemVersion, currentDevice.model]];
7783

78-
//Init rooms manager to start receiving NSNotificationCenter notifications
84+
// Init rooms manager to start receiving NSNotificationCenter notifications
7985
[NCRoomsManager sharedInstance];
8086

8187
[self registerBackgroundFetchTask];

NextcloudTalk/NCAPIController.m

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ - (void)initImageDownloaders
150150
// Don't set the path to an app group in order to prevent crashes
151151
[SDImageCache sharedImageCache].config.shouldDisableiCloud = YES;
152152
[SDImageCache sharedImageCache].config.maxDiskSize = 100 * 1024 * 1024;
153+
[SDImageCache sharedImageCache].config.maxDiskAge = 60 * 60 * 24 * 7 * 4; // 4 weeks
154+
155+
// We expire the cache once on app launch, see AppDelegate
156+
[SDImageCache sharedImageCache].config.shouldRemoveExpiredDataWhenTerminate = NO;
157+
[SDImageCache sharedImageCache].config.shouldRemoveExpiredDataWhenEnterBackground = NO;
153158

154159
NSString *userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (iOS) Nextcloud-Talk v%@",
155160
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];

NextcloudTalk/NCSettingsController.h

+1
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ typedef NS_ENUM(NSInteger, NCPreferredFileSorting) {
7777
- (void)setContactSync:(BOOL)enabled;
7878
- (BOOL)didReceiveCallsFromOldAccount;
7979
- (void)setDidReceiveCallsFromOldAccount:(BOOL)receivedOldCalls;
80+
- (void)createAccountsFile;
8081

8182
@end

NextcloudTalk/NCSettingsController.m

-7
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ - (id)init
9595
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRevokedResponseReceived:) name:NCTokenRevokedResponseReceivedNotification object:nil];
9696
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(upgradeRequiredResponseReceived:) name:NCUpgradeRequiredResponseReceivedNotification object:nil];
9797
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(talkConfigurationHasChanged:) name:NCTalkConfigurationHashChangedNotification object:nil];
98-
99-
// No need to create the file immediately -> dispatch to background
100-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){
101-
@autoreleasepool {
102-
[self createAccountsFile];
103-
}
104-
});
10598
}
10699
return self;
107100
}

0 commit comments

Comments
 (0)