Clean up ahead of PR.

pull/1/head
Matthew Chen 8 years ago
parent 137fe6fb8b
commit 5dcf4b3bbc

@ -134,13 +134,24 @@ NS_ASSUME_NONNULL_BEGIN
[UIAlertAction actionWithTitle:NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION_BUTTON", @"") [UIAlertAction actionWithTitle:NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION_BUTTON", @"")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[[TSStorageManager sharedManager] deleteThreadsAndMessages]; [self deleteThreadsAndMessages];
}]; }];
[alertController addAction:deleteAction]; [alertController addAction:deleteAction];
[self presentViewController:alertController animated:true completion:nil]; [self presentViewController:alertController animated:true completion:nil];
} }
- (void)deleteThreadsAndMessages
{
[TSStorageManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction removeAllObjectsInCollection:[TSThread collection]];
[transaction removeAllObjectsInCollection:[SignalRecipient collection]];
[transaction removeAllObjectsInCollection:[TSInteraction collection]];
[transaction removeAllObjectsInCollection:[TSAttachment collection]];
}];
[TSAttachmentStream deleteAttachments];
}
- (void)didToggleScreenSecuritySwitch:(UISwitch *)sender - (void)didToggleScreenSecuritySwitch:(UISwitch *)sender
{ {
BOOL enabled = sender.isOn; BOOL enabled = sender.isOn;

@ -23,7 +23,7 @@ NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress"; NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView"; NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion"; NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions"; NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions2";
NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered"; NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered";
@implementation OWSPreferences @implementation OWSPreferences

@ -305,7 +305,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)deleteAttachments + (void)deleteAttachments
{ {
NSError *error; NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *fileURL = [NSURL fileURLWithPath:self.attachmentsFolder]; NSURL *fileURL = [NSURL fileURLWithPath:self.attachmentsFolder];
@ -318,15 +317,11 @@ NS_ASSUME_NONNULL_BEGIN
} }
for (NSURL *url in contents) { for (NSURL *url in contents) {
NSError *deletionError; [fileManager removeItemAtURL:url error:&error];
[fileManager removeItemAtURL:url error:&deletionError]; if (error) {
if (deletionError) { OWSFail(@"failed to remove item at path: %@ with error: %@", url, error);
OWSFail(@"failed to remove item at path: %@ with error: %@", url, deletionError);
// continue to try to delete remaining items.
} }
} }
return;
} }
- (CGSize)calculateImageSize - (CGSize)calculateImageSize

@ -28,8 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)(void))safeBlockingMigrationsBlock; - (void)setupDatabaseWithSafeBlockingMigrations:(void (^_Nonnull)(void))safeBlockingMigrationsBlock;
- (void)deleteThreadsAndMessages;
// TODO: Deprecate. // TODO: Deprecate.
+ (YapDatabaseConnection *)dbReadConnection; + (YapDatabaseConnection *)dbReadConnection;
+ (YapDatabaseConnection *)dbReadWriteConnection; + (YapDatabaseConnection *)dbReadWriteConnection;

@ -201,16 +201,6 @@ NSString *const TSStorageManagerExceptionName_CouldNotCreateDatabaseDirectory
return TSStorageManager.sharedManager.dbReadWriteConnection; return TSStorageManager.sharedManager.dbReadWriteConnection;
} }
- (void)deleteThreadsAndMessages {
[self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction removeAllObjectsInCollection:[TSThread collection]];
[transaction removeAllObjectsInCollection:[SignalRecipient collection]];
[transaction removeAllObjectsInCollection:[TSInteraction collection]];
[transaction removeAllObjectsInCollection:[TSAttachment collection]];
}];
[TSAttachmentStream deleteAttachments];
}
- (void)deleteDatabaseFile - (void)deleteDatabaseFile
{ {
NSError *error; NSError *error;

Loading…
Cancel
Save