pull/120/head
Niels Andriesse 5 years ago
parent 1b3a1b55cc
commit a74dbf9a16

@ -782,12 +782,12 @@ static NSTimeInterval launchStartedAt;
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
NSDate *now = [NSDate new];
NSDate *lastProfilePictureUpload = (NSDate *)[userDefaults objectForKey:@"lastProfilePictureUpload"];
if ([now timeIntervalSinceDate:lastProfilePictureUpload] > 14 * 24 * 60 * 60) {
if (lastProfilePictureUpload != nil && [now timeIntervalSinceDate:lastProfilePictureUpload] > 14 * 24 * 60 * 60) {
OWSProfileManager *profileManager = OWSProfileManager.sharedManager;
NSString *displayName = [profileManager profileNameForRecipientId:userHexEncodedPublicKey];
UIImage *profilePicture = [profileManager profileAvatarForRecipientId:userHexEncodedPublicKey];
[profileManager updateLocalProfileName:displayName avatarImage:profilePicture success:^{
[userDefaults setObject:now forKey:@"lastProfilePictureUpload"];
// Do nothing; the user defaults flag is updated in LokiFileServerAPI
} failure:^(NSError *error) {
// Do nothing
} requiresSync:YES];

@ -156,7 +156,7 @@ public final class LokiFileServerAPI : LokiDotNetAPI {
print("[Loki] Couldn't parse profile picture from: \(responseObject).")
throw LokiDotNetAPIError.parsingFailed
}
UserDefaults.standard[.lastProfilePictureUpload] = Date().timeIntervalSince1970
UserDefaults.standard[.lastProfilePictureUpload] = Date()
return downloadURL
}
}

Loading…
Cancel
Save