mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Convert backup logic to use promises.
This commit is contained in:
parent
e19b457cb3
commit
a9120906fa
|
@ -74,16 +74,16 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
__weak OWSBackupSettingsViewController *weakSelf = self;
|
||||
[[self.backup checkCloudKitAccess]
|
||||
.then(^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.iCloudError = nil;
|
||||
[weakSelf updateTableContents];
|
||||
});
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
weakSelf.iCloudError = nil;
|
||||
[weakSelf updateTableContents];
|
||||
})
|
||||
.catch(^(NSError *error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.iCloudError = error;
|
||||
[weakSelf updateTableContents];
|
||||
});
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
weakSelf.iCloudError = error;
|
||||
[weakSelf updateTableContents];
|
||||
}) retainUntilComplete];
|
||||
}
|
||||
|
||||
|
|
|
@ -90,16 +90,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *recipientId = self.tsAccountManager.localNumber;
|
||||
[[self.backup checkCloudKitAccess]
|
||||
.then(^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[OWSBackupAPI saveTestFileToCloudWithRecipientId:recipientId
|
||||
fileUrl:[NSURL fileURLWithPath:filePath]
|
||||
success:^(NSString *recordName) {
|
||||
// Do nothing, the API method will log for us.
|
||||
}
|
||||
failure:^(NSError *error){
|
||||
// Do nothing, the API method will log for us.
|
||||
}];
|
||||
});
|
||||
[OWSBackupAPI saveTestFileToCloudWithRecipientId:recipientId
|
||||
fileUrl:[NSURL fileURLWithPath:filePath]
|
||||
success:^(NSString *recordName) {
|
||||
// Do nothing, the API method will log for us.
|
||||
}
|
||||
failure:^(NSError *error){
|
||||
// Do nothing, the API method will log for us.
|
||||
}];
|
||||
})
|
||||
.catch(^(NSError *error){
|
||||
// Do nothing, the API method will log for us.
|
||||
|
|
|
@ -474,7 +474,7 @@ NSArray<NSString *> *MiscCollectionsToBackup(void)
|
|||
}
|
||||
|
||||
[[OWSBackupAPI checkCloudKitAccessObjc]
|
||||
.then(^{
|
||||
.thenInBackground(^{
|
||||
[OWSBackupAPI checkForManifestInCloudWithRecipientId:recipientId
|
||||
success:^(BOOL value) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
@ -488,9 +488,7 @@ NSArray<NSString *> *MiscCollectionsToBackup(void)
|
|||
}];
|
||||
})
|
||||
.catch(^(NSError *error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
failure(error);
|
||||
});
|
||||
failure(error);
|
||||
}) retainUntilComplete];
|
||||
}
|
||||
|
||||
|
|
|
@ -349,17 +349,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
__weak OWSBackupExportJob *weakSelf = self;
|
||||
[[self.backup checkCloudKitAccess]
|
||||
.then(^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf start];
|
||||
});
|
||||
.thenInBackground(^{
|
||||
[weakSelf start];
|
||||
})
|
||||
.catch(^(NSError *error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf failWithErrorDescription:
|
||||
NSLocalizedString(@"BACKUP_EXPORT_ERROR_COULD_NOT_EXPORT",
|
||||
@"Error indicating the backup export could not export the user's data.")];
|
||||
});
|
||||
[weakSelf failWithErrorDescription:
|
||||
NSLocalizedString(@"BACKUP_EXPORT_ERROR_COULD_NOT_EXPORT",
|
||||
@"Error indicating the backup export could not export the user's data.")];
|
||||
}) retainUntilComplete];
|
||||
}
|
||||
|
||||
|
|
|
@ -78,17 +78,13 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
|
|||
|
||||
__weak OWSBackupImportJob *weakSelf = self;
|
||||
[[self.backup checkCloudKitAccess]
|
||||
.then(^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf start];
|
||||
});
|
||||
.thenInBackground(^{
|
||||
[weakSelf start];
|
||||
})
|
||||
.catch(^(NSError *error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf failWithErrorDescription:
|
||||
NSLocalizedString(@"BACKUP_IMPORT_ERROR_COULD_NOT_IMPORT",
|
||||
@"Error indicating the backup import could not import the user's data.")];
|
||||
});
|
||||
[weakSelf failWithErrorDescription:
|
||||
NSLocalizedString(@"BACKUP_IMPORT_ERROR_COULD_NOT_IMPORT",
|
||||
@"Error indicating the backup import could not import the user's data.")];
|
||||
}) retainUntilComplete];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue