Proper error message on failed mark as unread in ios app.

This commit is contained in:
Samuel Clay 2013-02-06 18:42:15 -08:00
parent 3688ad342d
commit fe789de2c3
2 changed files with 28 additions and 11 deletions

View file

@ -952,7 +952,10 @@ heightForHeaderInSection:(NSInteger)section {
hud.mode = MBProgressHUDModeText;
hud.removeFromSuperViewOnHide = YES;
NSIndexPath *topRow = [[self.feedTitlesTable indexPathsForVisibleRows] objectAtIndex:0];
NSIndexPath *topRow;
if ([[self.feedTitlesTable indexPathsForVisibleRows] count]) {
topRow = [[self.feedTitlesTable indexPathsForVisibleRows] objectAtIndex:0];
}
int selectedSegmentIndex = [self.intelligenceControl selectedSegmentIndex];
self.stillVisibleFeeds = [NSMutableDictionary dictionary];
@ -988,14 +991,16 @@ heightForHeaderInSection:(NSInteger)section {
[self.feedTitlesTable reloadData];
NSIndexPath *newMiddleRow;
if ([self.feedTitlesTable numberOfRowsInSection:topRow.section] == 0) {
if (topRow && [self.feedTitlesTable numberOfRowsInSection:topRow.section] == 0) {
newMiddleRow = [[self.feedTitlesTable indexPathsForVisibleRows] objectAtIndex:0];
} else {
} else if (topRow) {
newMiddleRow = [NSIndexPath indexPathForRow:0 inSection:topRow.section];
}
[self.feedTitlesTable scrollToRowAtIndexPath:newMiddleRow
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
if (newMiddleRow) {
[self.feedTitlesTable scrollToRowAtIndexPath:newMiddleRow
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
}
[self.feedTitlesTable
reloadRowsAtIndexPaths:[self.feedTitlesTable indexPathsForVisibleRows]
withRowAnimation:direction == 1 ? UITableViewRowAnimationLeft : UITableViewRowAnimationRight];

View file

@ -554,13 +554,17 @@
}
}
- (void)requestFailed:(ASIHTTPRequest *)request {
NSLog(@"Error in story detail: %@", [request error]);
- (void)requestFailed:(id)request {
NSString *error;
if ([request error]) {
error = [NSString stringWithFormat:@"%@", [request error]];
if ([request class] == [ASIHTTPRequest class]) {
NSLog(@"Error in story detail: %@", [request error]);
if ([request error]) {
error = [NSString stringWithFormat:@"%@", [request error]];
} else {
error = @"The server barfed!";
}
} else {
error = @"The server barfed!";
error = request;
}
[self informError:error];
}
@ -786,6 +790,14 @@
return [self requestFailed:request];
}
NSString *responseString = [request responseString];
NSDictionary *results = [[NSDictionary alloc]
initWithDictionary:[responseString JSONValue]];
if ([[results objectForKey:@"code"] intValue] < 0) {
return [self requestFailed:[results objectForKey:@"message"]];
}
[appDelegate markActiveStoryUnread];
[appDelegate.feedDetailViewController redrawUnreadStory];