Mhurd has uploaded a new change for review. https://gerrit.wikimedia.org/r/117089
Change subject: Fix for save no longer working if initial save attempt failed. ...................................................................... Fix for save no longer working if initial save attempt failed. Change-Id: I3544a26cbe576ccadcce1be28c56f5d80f0f38fb --- M Wikipedia-iOS/Categories/Alerts/UIViewController+Alert.m M Wikipedia-iOS/Queues/QueuesSingleton.h M Wikipedia-iOS/Queues/QueuesSingleton.m M Wikipedia-iOS/View Controllers/ArticleLanguages/ArticleLanguagesTableVC.m M Wikipedia-iOS/View Controllers/Preview/PreviewAndSaveViewController.m M Wikipedia-iOS/View Controllers/SectionEditor/SectionEditorViewController.m 6 files changed, 45 insertions(+), 32 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia refs/changes/89/117089/1 diff --git a/Wikipedia-iOS/Categories/Alerts/UIViewController+Alert.m b/Wikipedia-iOS/Categories/Alerts/UIViewController+Alert.m index 41a136f..dc331f8 100644 --- a/Wikipedia-iOS/Categories/Alerts/UIViewController+Alert.m +++ b/Wikipedia-iOS/Categories/Alerts/UIViewController+Alert.m @@ -9,6 +9,8 @@ -(void)showAlert:(NSString *)alertText { + //NSLog(@"alertText = %@", alertText); + [[NSOperationQueue mainQueue] addOperationWithBlock: ^ { AlertLabel *alertLabel = nil; diff --git a/Wikipedia-iOS/Queues/QueuesSingleton.h b/Wikipedia-iOS/Queues/QueuesSingleton.h index 944cb56..6d93d69 100644 --- a/Wikipedia-iOS/Queues/QueuesSingleton.h +++ b/Wikipedia-iOS/Queues/QueuesSingleton.h @@ -10,7 +10,9 @@ @property (strong, nonatomic) NSOperationQueue *thumbnailQ; @property (strong, nonatomic) NSOperationQueue *zeroRatedMessageStringQ; -@property (strong, nonatomic) NSOperationQueue *sectionWikiTextQ; +@property (strong, nonatomic) NSOperationQueue *sectionWikiTextDownloadQ; +@property (strong, nonatomic) NSOperationQueue *sectionWikiTextUploadQ; +@property (strong, nonatomic) NSOperationQueue *sectionWikiTextPreviewQ; @property (strong, nonatomic) NSOperationQueue *langLinksQ; @property (strong, nonatomic) NSOperationQueue *accountCreationQ; diff --git a/Wikipedia-iOS/Queues/QueuesSingleton.m b/Wikipedia-iOS/Queues/QueuesSingleton.m index 80fde12..180f6f7 100644 --- a/Wikipedia-iOS/Queues/QueuesSingleton.m +++ b/Wikipedia-iOS/Queues/QueuesSingleton.m @@ -22,7 +22,9 @@ self.articleRetrievalQ = [[NSOperationQueue alloc] init]; self.searchQ = [[NSOperationQueue alloc] init]; self.thumbnailQ = [[NSOperationQueue alloc] init]; - self.sectionWikiTextQ = [[NSOperationQueue alloc] init]; + self.sectionWikiTextDownloadQ = [[NSOperationQueue alloc] init]; + self.sectionWikiTextUploadQ = [[NSOperationQueue alloc] init]; + self.sectionWikiTextPreviewQ = [[NSOperationQueue alloc] init]; self.langLinksQ = [[NSOperationQueue alloc] init]; self.zeroRatedMessageStringQ = [[NSOperationQueue alloc] init]; self.accountCreationQ = [[NSOperationQueue alloc] init]; diff --git a/Wikipedia-iOS/View Controllers/ArticleLanguages/ArticleLanguagesTableVC.m b/Wikipedia-iOS/View Controllers/ArticleLanguages/ArticleLanguagesTableVC.m index f080d67..db724a0 100644 --- a/Wikipedia-iOS/View Controllers/ArticleLanguages/ArticleLanguagesTableVC.m +++ b/Wikipedia-iOS/View Controllers/ArticleLanguages/ArticleLanguagesTableVC.m @@ -31,7 +31,6 @@ -(void)downloadLangLinkData { - [[QueuesSingleton sharedInstance].langLinksQ cancelAllOperations]; //TODO: fix "showAlert" to work with table view controllers. //[self showAlert:@"Loading language links..."]; @@ -56,6 +55,7 @@ }]; + [[QueuesSingleton sharedInstance].langLinksQ cancelAllOperations]; [[QueuesSingleton sharedInstance].langLinksQ addOperation:langLinksOp]; } diff --git a/Wikipedia-iOS/View Controllers/Preview/PreviewAndSaveViewController.m b/Wikipedia-iOS/View Controllers/Preview/PreviewAndSaveViewController.m index 5de5242..84eca7f 100644 --- a/Wikipedia-iOS/View Controllers/Preview/PreviewAndSaveViewController.m +++ b/Wikipedia-iOS/View Controllers/Preview/PreviewAndSaveViewController.m @@ -175,8 +175,8 @@ previewWikiTextOp.delegate = self; - [[QueuesSingleton sharedInstance].sectionWikiTextQ cancelAllOperations]; - [[QueuesSingleton sharedInstance].sectionWikiTextQ addOperation:previewWikiTextOp]; + [[QueuesSingleton sharedInstance].sectionWikiTextPreviewQ cancelAllOperations]; + [[QueuesSingleton sharedInstance].sectionWikiTextPreviewQ addOperation:previewWikiTextOp]; } - (void)didReceiveMemoryWarning @@ -199,8 +199,9 @@ NSManagedObjectID *articleID = section.article.objectID; - UploadSectionWikiTextOp *uploadWikiTextOp = [[UploadSectionWikiTextOp alloc] initForPageTitle:section.article.title domain:section.article.domain section:section.index wikiText:self.wikiText captchaId:self.captchaId captchaWord:self.captchaViewController.captchaTextBox.text completionBlock:^(NSString *result){ - + UploadSectionWikiTextOp *uploadWikiTextOp = + [[UploadSectionWikiTextOp alloc] initForPageTitle:section.article.title domain:section.article.domain section:section.index wikiText:self.wikiText captchaId:self.captchaId captchaWord:self.captchaViewController.captchaTextBox.text completionBlock:^(NSString *result){ + // Mark article for refreshing so its data will be reloaded. // (Needs to be done on worker context as worker context changes bubble up through // main context too - so web view controller accessing main context will see changes.) @@ -325,24 +326,29 @@ isAleadySaving = NO; }]; - EditTokenOp *editTokenOp = [[EditTokenOp alloc] initWithDomain: section.article.domain - completionBlock: ^(NSDictionary *result){ - //NSLog(@"editTokenOp result = %@", result); - //NSLog(@"editTokenOp result tokens = %@", result[@"tokens"][@"edittoken"]); - - NSString *editToken = result[@"tokens"][@"edittoken"]; - NSMutableDictionary *editTokens = [SessionSingleton sharedInstance].keychainCredentials.editTokens; - editTokens[[SessionSingleton sharedInstance].domain] = editToken; - [SessionSingleton sharedInstance].keychainCredentials.editTokens = editTokens; - - } cancelledBlock: ^(NSError *error){ - - [self showAlert:@""]; - - } errorBlock: ^(NSError *error){ - - [self showAlert:error.localizedDescription]; - }]; + EditTokenOp *editTokenOp = + [[EditTokenOp alloc] initWithDomain: section.article.domain + completionBlock: ^(NSDictionary *result){ + //NSLog(@"editTokenOp result = %@", result); + //NSLog(@"editTokenOp result tokens = %@", result[@"tokens"][@"edittoken"]); + + NSString *editToken = result[@"tokens"][@"edittoken"]; + NSMutableDictionary *editTokens = [SessionSingleton sharedInstance].keychainCredentials.editTokens; + editTokens[[SessionSingleton sharedInstance].domain] = editToken; + [SessionSingleton sharedInstance].keychainCredentials.editTokens = editTokens; + + } cancelledBlock: ^(NSError *error){ + + [self showAlert:@""]; + + isAleadySaving = NO; + + } errorBlock: ^(NSError *error){ + + [self showAlert:error.localizedDescription]; + isAleadySaving = NO; + + }]; //TODO: if we have credentials, yet the edit token retrieved for an edit is // an anonymous token (i think this happens if you try to get an edit token @@ -362,13 +368,13 @@ // Try to get an edit token for the page's domain before trying to upload the changes. [uploadWikiTextOp addDependency:editTokenOp]; - [[QueuesSingleton sharedInstance].sectionWikiTextQ cancelAllOperations]; - [QueuesSingleton sharedInstance].sectionWikiTextQ.suspended = YES; + [[QueuesSingleton sharedInstance].sectionWikiTextUploadQ cancelAllOperations]; + [QueuesSingleton sharedInstance].sectionWikiTextUploadQ.suspended = YES; - [[QueuesSingleton sharedInstance].sectionWikiTextQ addOperation:editTokenOp]; - [[QueuesSingleton sharedInstance].sectionWikiTextQ addOperation:uploadWikiTextOp]; + [[QueuesSingleton sharedInstance].sectionWikiTextUploadQ addOperation:editTokenOp]; + [[QueuesSingleton sharedInstance].sectionWikiTextUploadQ addOperation:uploadWikiTextOp]; - [QueuesSingleton sharedInstance].sectionWikiTextQ.suspended = NO; + [QueuesSingleton sharedInstance].sectionWikiTextUploadQ.suspended = NO; } - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender diff --git a/Wikipedia-iOS/View Controllers/SectionEditor/SectionEditorViewController.m b/Wikipedia-iOS/View Controllers/SectionEditor/SectionEditorViewController.m index 2f1f3cf..c2078d5 100644 --- a/Wikipedia-iOS/View Controllers/SectionEditor/SectionEditorViewController.m +++ b/Wikipedia-iOS/View Controllers/SectionEditor/SectionEditorViewController.m @@ -184,8 +184,9 @@ [self showAlert:errorMsg]; }]; - - [[QueuesSingleton sharedInstance].sectionWikiTextQ addOperation:downloadWikiTextOp]; + + [[QueuesSingleton sharedInstance].sectionWikiTextDownloadQ cancelAllOperations]; + [[QueuesSingleton sharedInstance].sectionWikiTextDownloadQ addOperation:downloadWikiTextOp]; } -(void)adjustScrollInset -- To view, visit https://gerrit.wikimedia.org/r/117089 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3544a26cbe576ccadcce1be28c56f5d80f0f38fb Gerrit-PatchSet: 1 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Mhurd <mh...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits