Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve avatar caching #2004

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NextcloudTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4313,7 +4313,7 @@
repositoryURL = "https://github.com/SDWebImage/SDWebImage.git";
requirement = {
kind = exactVersion;
version = 5.15.7;
version = 5.20.1;
};
};
1F45A11F2A01D8BA005FE87D /* XCRemoteSwiftPackageReference "SDWebImageSVGKitPlugin" */ = {
Expand Down
14 changes: 10 additions & 4 deletions NextcloudTalk/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#import <BackgroundTasks/BGTaskRequest.h>
#import <BackgroundTasks/BGTask.h>

#import <SDWebImage/SDImageCache.h>

#import "NCAudioController.h"
#import "NCAppBranding.h"
#import "NCDatabaseManager.h"
Expand Down Expand Up @@ -67,15 +69,19 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
NSLog(@"Configure App Settings");
[NCSettingsController sharedInstance];

// Perform logfile cleanup only once in app lifecycle
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[NCUtils removeOldLogfiles];
// Perform cleanup only once in app lifecycle
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void){
@autoreleasepool {
[NCUtils removeOldLogfiles];
[[SDImageCache sharedImageCache].diskCache removeExpiredData];
[[NCSettingsController sharedInstance] createAccountsFile];
}
});

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

//Init rooms manager to start receiving NSNotificationCenter notifications
// Init rooms manager to start receiving NSNotificationCenter notifications
[NCRoomsManager sharedInstance];

[self registerBackgroundFetchTask];
Expand Down
5 changes: 5 additions & 0 deletions NextcloudTalk/NCAPIController.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ - (void)initImageDownloaders
// Don't set the path to an app group in order to prevent crashes
[SDImageCache sharedImageCache].config.shouldDisableiCloud = YES;
[SDImageCache sharedImageCache].config.maxDiskSize = 100 * 1024 * 1024;
[SDImageCache sharedImageCache].config.maxDiskAge = 60 * 60 * 24 * 7 * 4; // 4 weeks

// We expire the cache once on app launch, see AppDelegate
[SDImageCache sharedImageCache].config.shouldRemoveExpiredDataWhenTerminate = NO;
[SDImageCache sharedImageCache].config.shouldRemoveExpiredDataWhenEnterBackground = NO;

NSString *userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (iOS) Nextcloud-Talk v%@",
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
Expand Down
1 change: 1 addition & 0 deletions NextcloudTalk/NCSettingsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ typedef NS_ENUM(NSInteger, NCPreferredFileSorting) {
- (void)setContactSync:(BOOL)enabled;
- (BOOL)didReceiveCallsFromOldAccount;
- (void)setDidReceiveCallsFromOldAccount:(BOOL)receivedOldCalls;
- (void)createAccountsFile;

@end
7 changes: 0 additions & 7 deletions NextcloudTalk/NCSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ - (id)init
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRevokedResponseReceived:) name:NCTokenRevokedResponseReceivedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(upgradeRequiredResponseReceived:) name:NCUpgradeRequiredResponseReceivedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(talkConfigurationHasChanged:) name:NCTalkConfigurationHashChangedNotification object:nil];

// No need to create the file immediately -> dispatch to background
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){
@autoreleasepool {
[self createAccountsFile];
}
});
}
return self;
}
Expand Down
Loading