One time thumbnail generation

// FREEBIE
This commit is contained in:
Michael Kirk 2018-03-19 13:00:19 -04:00
parent a0bd2c2324
commit 96e5a8f4b7
3 changed files with 29 additions and 1 deletions

View file

@ -1147,6 +1147,18 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[[OWSMessageReceiver sharedInstance] handleAnyUnprocessedEnvelopesAsync];
[[OWSBatchMessageProcessor sharedInstance] handleAnyUnprocessedEnvelopesAsync];
if (!Environment.preferences.hasGeneratedThumbnails) {
[OWSPrimaryStorage.sharedManager.newDatabaseConnection
asyncReadWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
[TSAttachmentStream enumerateCollectionObjectsUsingBlock:^(id _Nonnull obj, BOOL *_Nonnull stop){
// no-op. It's sufficient to initWithCoder: each object.
}];
}
completionBlock:^{
[Environment.preferences setHasGeneratedThumbnails:YES];
}];
}
#ifdef DEBUG
// A bug in orphan cleanup could be disastrous so let's only
// run it in DEBUG builds for a few releases.

View file

@ -61,6 +61,9 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
- (void)setIOSUpgradeNagDate:(NSDate *)value;
- (nullable NSDate *)iOSUpgradeNagDate;
- (BOOL)hasGeneratedThumbnails;
- (void)setHasGeneratedThumbnails:(BOOL)value;
#pragma mark - Calling
#pragma mark Callkit

View file

@ -4,11 +4,11 @@
#import "OWSPreferences.h"
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/NSNotificationCenter+OWS.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h>
#import <SignalServiceKit/TSStorageHeaders.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
#import <SignalServiceKit/YapDatabaseTransaction+OWS.h>
#import <SignalServiceKit/NSNotificationCenter+OWS.h>
NS_ASSUME_NONNULL_BEGIN
@ -28,6 +28,7 @@ NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyRemoveMetadata = @"Remove Metadata Key";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHasGeneratedThumbnails";
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled";
@ -194,6 +195,18 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
[self setValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView toValue:@(value)];
}
- (BOOL)hasGeneratedThumbnails
{
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyHasGeneratedThumbnails];
// Default to NO.
return preference ? [preference boolValue] : NO;
}
- (void)setHasGeneratedThumbnails:(BOOL)value
{
[self setValueForKey:OWSPreferencesKeyHasGeneratedThumbnails toValue:@(value)];
}
- (void)setIOSUpgradeNagDate:(NSDate *)value
{
[self setValueForKey:OWSPreferencesKeyIOSUpgradeNagDate toValue:value];