Medium 2.9.3100

NICK 🅵🅸🆂🅷ER
Medium Release Notes
2 min readMar 23, 2016

The one where we got really specific about what changed.

Yesterday, we introduced a bug that caused the app to crash for some users. This has been fixed. In an effort to be even more transparent, here is exactly what changed in this release:

Showing 13 changed files with 56 additions and 560 deletions.

View app/Components/PostList/PostListDataController.h:

@property (nonatomic, readonly) ListDataControllerState *postListState;

- — (void)reloadPostsWithSession:(Session *)session; // PTR

- — (void)fetchInitialPageWithSession:(Session *)session; // loading when you open the app

- — (void)fetchNextPageWithSession:(Session *)session; // infinite scroll

+ — (void)reloadPostsWithSession:(Session *)session;

+ — (void)fetchNextPageWithSession:(Session *)session;

View app/Components/PostList/PostListDataController.m:

_postListState = [ListDataControllerState stateWithItems:@[]

pagingState:ListDataControllerPagingStateInitialFetch

error:nil];

- _inResponseToPostsByPostId = [NSMutableDictionary dictionary];

- _socialRecommendUsersByPostId = [NSMutableDictionary dictionary];

}

return self;

}

- — (void)fetchInitialPageWithSession:(Session *)session {

- [self fetchInitialPageWithSession:session shouldClearList:NO];

- }

-

- (void)reloadPostsWithSession:(Session *)session {

- [self fetchInitialPageWithSession:session shouldClearList:YES];

+ if (_isFetching) {

+ GRTLogInfo(@”Attempt to reload posts with fetch already in progress”);

+ return;

+ }

+ _isFetching = YES;

+

+ // Load the cached list if it exists, but only on the initial fetch

+ if ([_fetcher respondsToSelector:@selector(cachedPostListRespone)] &&

+ _postListState.items.count == 0) {

+ PostListResponse *cachedResponse = [_fetcher cachedPostListRespone];

+ if (cachedResponse.postListItems.count && cachedResponse.paging) {

+ GRTLogInfo(@”Cached post list found!”);

+ [self processInitialPostListResponse:cachedResponse

+ error:nil];

+ }

+ }

+

+ // Fetch a fresh list from the server

+ [_fetcher fetchInitialListWithCompletion:^(NSArray *postListItems,

+ id(MediumAPIPaging) paging,

+ NSError *error) {

+ PostListResponse *response = [[PostListResponse alloc] initWithStreamItems:postListItems

+ inResponseToPostsByPostId:inResponseToPostsByPostId

+ socialRecommendUsersByPostId:socialRecommendUsersByPostId

+ paging:paging];

+ [self processInitialPostListResponse:response

+ error:error];

+ }];

}
-
— (void)processInitialPostListResponse:(PostListResponse *)response
- error:(NSError *)error
- shouldClearList:(BOOL)shouldClear {
+ error:(NSError *)error {
_isFetching = NO;
if (error) {
// If we already have items, just silently fail so we don’t clobber the entire stream on a failure
return;
}

- NSArray *existingPostList = _postListState.items ?: @[];
- NSArray *incomingPostList = response.postListItems ?: @[];
-
- if (shouldClear) {
- [_inResponseToPostsByPostId removeAllObjects];
- [_socialRecommendUsersByPostId removeAllObjects];
- existingPostList = @[];
- }
-

--

--