Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions WordPress/Classes/CommentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ - (void)viewDidLoad {
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}

- (UIColor *)backgroundColorForRefreshHeaderView
{
return [WPStyleGuide itsEverywhereGrey];
}

- (void)viewWillAppear:(BOOL)animated {
WPFLogMethod();

Expand Down Expand Up @@ -145,7 +140,7 @@ - (void)setWantedCommentId:(NSNumber *)wantedCommentId {
[self willChangeValueForKey:@"wantedCommentId"];
_wantedCommentId = wantedCommentId;
[self didChangeValueForKey:@"wantedCommentId"];
[self syncItemsWithUserInteraction:NO];
[self syncItems];
}
}
}
Expand Down Expand Up @@ -228,7 +223,7 @@ - (UITableViewCell *)newCell {
return cell;
}

- (void)syncItemsWithUserInteraction:(BOOL)userInteraction success:(void (^)())success failure:(void (^)(NSError *))failure {
- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
[self.blog syncCommentsWithSuccess:success failure:failure];
}

Expand Down
26 changes: 14 additions & 12 deletions WordPress/Classes/NotificationsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ - (void)viewDidAppear:(BOOL)animated {
}

_isPushingViewController = NO;
// If table is at the top, simulate a pull to refresh
BOOL simulatePullToRefresh = (self.tableView.contentOffset.y == 0);
[self syncItemsWithUserInteraction:simulatePullToRefresh];

// If table is at the top (i.e. freshly opened), do some extra work
if (self.tableView.contentOffset.y == 0) {
[self pruneOldNotes];
}

[self syncItems];
[self refreshUnreadNotes];
}

Expand All @@ -89,10 +93,6 @@ - (void)viewDidDisappear:(BOOL)animated {
[self pruneOldNotes];
}

- (UIColor *)backgroundColorForRefreshHeaderView
{
return [WPStyleGuide itsEverywhereGrey];
}

#pragma mark - Custom methods

Expand Down Expand Up @@ -141,7 +141,7 @@ - (void)refreshFromPushNotification {
[self.panelNavigationController popToRootViewControllerAnimated:YES];
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
if (![self isSyncing]) {
[self syncItemsWithUserInteraction:NO];
[self syncItems];
}
}

Expand Down Expand Up @@ -234,10 +234,12 @@ - (void)configureCell:(NewNotificationsTableViewCell *)cell atIndexPath:(NSIndex
cell.note = [self.resultsController objectAtIndexPath:indexPath];
}

- (void)syncItemsWithUserInteraction:(BOOL)userInteraction success:(void (^)())success failure:(void (^)(NSError *error))failure {
if (userInteraction) {
[self pruneOldNotes];
}
- (void)syncItemsViaUserInteractionWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
[self pruneOldNotes];
[self syncItemsWithSuccess:success failure:failure];
}

- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *error))failure {
NSNumber *timestamp;
NSArray *notes = [self.resultsController fetchedObjects];
if ([notes count] > 0) {
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/PagesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (NSString *)noResultsText
}


- (void)syncItemsWithUserInteraction:(BOOL)userInteraction success:(void (^)())success failure:(void (^)(NSError *))failure {
- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
[self.blog syncPagesWithSuccess:success failure:failure loadMore: NO];
}

Expand Down
19 changes: 7 additions & 12 deletions WordPress/Classes/PostsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ - (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (UIColor *)backgroundColorForRefreshHeaderView
{
return [WPStyleGuide itsEverywhereGrey];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
WordPressAppDelegate *delegate = (WordPressAppDelegate*)[[UIApplication sharedApplication] delegate];

Expand Down Expand Up @@ -248,7 +243,7 @@ - (void)deletePostAtIndexPath:(NSIndexPath *)indexPath{
} else {
[[NSNotificationCenter defaultCenter] postNotificationName:kXML_RPC_ERROR_OCCURS object:error userInfo:errInfo];
}
[self syncItemsWithUserInteraction:NO];
[self syncItems];
if(IS_IPAD && self.postReaderViewController) {
if(self.postReaderViewController.apost == post) {
//push an the W logo on the right.
Expand Down Expand Up @@ -368,13 +363,13 @@ - (NSString *)sectionNameKeyPath {
return @"remoteStatusNumber";
}

- (void)syncItemsWithUserInteraction:(BOOL)userInteraction success:(void (^)())success failure:(void (^)(NSError *))failure {
- (void)syncItemsViaUserInteractionWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
// If triggered by a pull to refresh, sync categories, post formats, ...
if (userInteraction) {
[self.blog syncBlogPostsWithSuccess:success failure:failure];
} else {
[self.blog syncPostsWithSuccess:success failure:failure loadMore:NO];
}
[self.blog syncBlogPostsWithSuccess:success failure:failure];
}

- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
[self.blog syncPostsWithSuccess:success failure:failure loadMore:NO];
}

- (UITableViewCell *)newCell {
Expand Down
14 changes: 5 additions & 9 deletions WordPress/Classes/ReaderPostsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ - (void)fetchBlogsAndPrimaryBlog;
- (void)handleReblogButtonTapped:(id)sender;
- (void)showReblogForm;
- (void)hideReblogForm;
- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure;
- (void)onSyncSuccess:(AFHTTPRequestOperation *)operation response:(id)responseObject;
- (void)handleKeyboardDidShow:(NSNotification *)notification;
- (void)handleKeyboardWillHide:(NSNotification *)notification;
Expand Down Expand Up @@ -629,11 +628,11 @@ - (BOOL)hasMoreContent {
}


- (void)syncItemsWithUserInteraction:(BOOL)userInteraction success:(void (^)())success failure:(void (^)(NSError *))failure {
- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
WPFLogMethod();
// if needs auth.
if([WPCookie hasCookieForURL:[NSURL URLWithString:@"https://wordpress.com"] andUsername:[[WPAccount defaultWordPressComAccount] username]]) {
[self syncItemsWithSuccess:success failure:failure];
[self syncReaderItemsWithSuccess:success failure:failure];
return;
}

Expand All @@ -656,17 +655,17 @@ - (void)syncItemsWithUserInteraction:(BOOL)userInteraction success:(void (^)())s
AFHTTPRequestOperation *authRequest = [[AFHTTPRequestOperation alloc] initWithRequest:mRequest];
[authRequest setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[[WordPressAppDelegate sharedWordPressApplicationDelegate] useAppUserAgent];
[self syncItemsWithSuccess:success failure:failure];
[self syncReaderItemsWithSuccess:success failure:failure];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[[WordPressAppDelegate sharedWordPressApplicationDelegate] useAppUserAgent];
[self syncItemsWithSuccess:success failure:failure];
[self syncReaderItemsWithSuccess:success failure:failure];
}];

[authRequest start];
}


- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
- (void)syncReaderItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
WPFLogMethod();
NSString *endpoint = [ReaderPost currentEndpoint];
NSNumber *numberToSync = [NSNumber numberWithInteger:ReaderPostsToSync];
Expand Down Expand Up @@ -834,9 +833,6 @@ - (void)readerTopicChanged {
if ([WordPressAppDelegate sharedWordPressApplicationDelegate].connectionAvailable == YES && ![self isSyncing] ) {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:ReaderLastSyncDateKey];
[NSUserDefaults resetStandardUserDefaults];
if (IS_IPAD) {
[self simulatePullToRefresh];
}
}

if ([self isCurrentCategoryFreshlyPressed]) {
Expand Down
5 changes: 1 addition & 4 deletions WordPress/Classes/WPTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
#import "Blog.h"
#import "SettingsViewControllerDelegate.h"

//@interface WPTableViewController : UITableViewController <NSFetchedResultsControllerDelegate, UIAlertViewDelegate, SettingsViewControllerDelegate>
@interface WPTableViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, NSFetchedResultsControllerDelegate, UIAlertViewDelegate, SettingsViewControllerDelegate>
@interface WPTableViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate, NSFetchedResultsControllerDelegate, UIAlertViewDelegate, SettingsViewControllerDelegate>

@property (nonatomic, strong) Blog *blog;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, readonly) BOOL isScrolling;
@property (nonatomic) BOOL incrementalLoadingSupported;

- (void)promptForPassword;
- (UIColor *)backgroundColorForRefreshHeaderView;
- (NSString *)noResultsText;

@end
Loading