Skip to content

Commit

Permalink
Fix feed not showing photos and crash
Browse files Browse the repository at this point in the history
Tableview was getting out of sync with section objects
  • Loading branch information
hbridge committed Aug 26, 2014
1 parent feaa433 commit 7f0917d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions strand/iOS/Strand/Strand/DFStrandsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,25 @@ - (void)refreshView
* Refresh the current view. Very cheap and fast.
* Figures out if there's any photos currently being processed, to be shown in the uploading bar
* Then calls the child view to re-render
* Needs to happen async on main thread because setSectionObjects happens async on main thread
*/
- (void)refreshView:(BOOL)withNewServerData
{
BOOL newData = withNewServerData;
NSArray *unprocessedFeedPhotos = [self unprocessedFeedPhotos:self.sectionObjects];

if (![self.uploadingPhotos isEqualToArray:unprocessedFeedPhotos]) {
self.uploadingPhotos = unprocessedFeedPhotos;
DDLogDebug(@"Setting uploaded photos to count %lu", (unsigned long)self.uploadingPhotos.count);
newData = YES;
}

if (self.delegate && newData) {
DDLogInfo(@"Refreshing the view.");
[self.delegate strandsViewControllerUpdatedData:self];
}
dispatch_async(dispatch_get_main_queue(), ^{
BOOL newData = withNewServerData;
NSArray *unprocessedFeedPhotos = [self unprocessedFeedPhotos:self.sectionObjects];

if (![self.uploadingPhotos isEqualToArray:unprocessedFeedPhotos]) {
self.uploadingPhotos = unprocessedFeedPhotos;
DDLogDebug(@"Setting uploaded photos to count %lu", (unsigned long)self.uploadingPhotos.count);
newData = YES;
}

if (self.delegate && newData) {
DDLogInfo(@"Refreshing the view.");
[self.delegate strandsViewControllerUpdatedData:self];
}
});
}

#pragma mark - Strand data fetching
Expand Down

0 comments on commit 7f0917d

Please sign in to comment.