Nearly finished.

This commit is contained in:
Samuel Clay 2017-04-03 12:49:01 -07:00
parent f4a98f2998
commit 8bbfa8f270
16 changed files with 83 additions and 82 deletions

View file

@ -12,7 +12,9 @@
@class NewsBlurAppDelegate;
@interface AddSiteViewController : BaseViewController
<UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource>
<UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource> {
NewsBlurAppDelegate *appDelegate;
}
- (void)reload;
- (IBAction)addSite;
@ -24,7 +26,6 @@
- (IBAction)toggleAddFolder:(id)sender;
- (NSArray *)folders;
@property (nonatomic) IBOutlet NewsBlurAppDelegate *appDelegate;
@property (nonatomic) IBOutlet UITextField *inFolderInput;
@property (nonatomic) IBOutlet UITextField *addFolderInput;
@property (nonatomic) IBOutlet UITextField *siteAddressInput;

View file

@ -27,11 +27,14 @@
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
}
return self;
}
- (void)viewDidLoad {
appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(doCancelButton)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Add Site" style:UIBarButtonItemStyleDone target:self action:@selector(addSite)];
@ -120,9 +123,9 @@
- (IBAction)doCancelButton {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.appDelegate hidePopover];
[appDelegate hidePopover];
} else {
[self.appDelegate hidePopoverAnimated:YES];
[appDelegate hidePopoverAnimated:YES];
}
}
@ -194,8 +197,8 @@
[self.siteActivityIndicator startAnimating];
NSString *urlString = [NSString stringWithFormat:@"%@/rss_feeds/feed_autocomplete?term=%@&v=2",
self.appDelegate.url, [phrase stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
appDelegate.url, [phrase stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSString *query = [NSString stringWithFormat:@"%@", [responseObject objectForKey:@"term"]];
NSString *phrase = self.siteAddressInput.text;
@ -239,7 +242,7 @@
[self.errorLabel setHidden:YES];
[self.activityIndicator startAnimating];
NSString *urlString = [NSString stringWithFormat:@"%@/reader/add_url",
self.appDelegate.url];
appDelegate.url];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *parent_folder = [self extractParentFolder];
@ -249,7 +252,7 @@
[params setObject:[self.addFolderInput text] forKey:@"new_folder"];
}
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self.addingLabel setHidden:YES];
[self.activityIndicator stopAnimating];
@ -260,11 +263,11 @@
[self.errorLabel setHidden:NO];
} else {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.appDelegate hidePopover];
[appDelegate hidePopover];
} else {
[self.appDelegate hidePopoverAnimated:YES];
[appDelegate hidePopoverAnimated:YES];
}
[self.appDelegate reloadFeedsView:NO];
[appDelegate reloadFeedsView:NO];
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
@ -324,7 +327,7 @@
}
- (NSArray *)folders {
return _.without([self.appDelegate dictFoldersArray],
return _.without([appDelegate dictFoldersArray],
@[@"saved_stories",
@"read_stories",
@"river_blurblogs",
@ -367,7 +370,7 @@
viewController.checkedRow = [folders indexOfObject:self.inFolderInput.text] + 1;
}
[self.appDelegate.addSiteNavigationController pushViewController:viewController animated:YES];
[appDelegate.addSiteNavigationController pushViewController:viewController animated:YES];
}
#pragma mark -

View file

@ -16,7 +16,9 @@ typedef NS_ENUM(NSUInteger, FeedChooserOperation)
};
@interface FeedChooserViewController : BaseViewController
@interface FeedChooserViewController : BaseViewController {
NewsBlurAppDelegate *appDelegate;
}
@property (weak) IBOutlet UITableView *tableView;

View file

@ -42,6 +42,8 @@ static const CGFloat kFolderTitleHeight = 36.0;
- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
self.optionsItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_icn_settings.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showOptionsMenu)];
@ -96,7 +98,7 @@ static const CGFloat kFolderTitleHeight = 36.0;
}
NSString *urlString = [NSString stringWithFormat:@"%@/reader/feeds?flat=true&update_counts=false&include_inactive=true", self.appDelegate.url];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishLoadingInactiveFeeds:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self finishedWithError:error];
@ -460,7 +462,7 @@ static const CGFloat kFolderTitleHeight = 36.0;
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:feedsByFolder.JSONRepresentation forKey:@"feeds_by_folder"];
[params setObject:toFolder.identifier forKey:@"to_folder"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
HUD.labelText = @"Reloading...";
[self.appDelegate reloadFeedsView:YES];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

View file

@ -521,7 +521,7 @@
storiesCollection.searchQuery = nil;
[self.searchBar setText:@""];
[self.notifier hideIn:0];
[self cancelRequests];
// [self cancelRequests];
[self beginOfflineTimer];
[appDelegate.cacheImagesOperationQueue cancelAllOperations];
}
@ -705,10 +705,12 @@
theFeedDetailURL,
[storiesCollection.searchQuery stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];
}
[self cancelRequests];
[manager GET:theFeedDetailURL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
// [self cancelRequests];
NSString *feedId = [[storiesCollection activeFeed] objectForKey:@"id"];
NSInteger feedPage = storiesCollection.feedPage;
[appDelegate.networkManager GET:theFeedDetailURL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
if (!storiesCollection.activeFeed) return;
[self finishedLoadingFeed:responseObject withResponse:task.response];
[self finishedLoadingFeed:responseObject withResponse:task.response feedPage:feedPage feedId:feedId];
if (callback) {
callback();
}
@ -720,7 +722,6 @@
[self showOfflineNotifier];
[self.storyTitlesTable reloadData];
}];
[request setUserInfo:@{@"feedPage": [NSNumber numberWithInt:storiesCollection.feedPage], @"feedId": [[storiesCollection activeFeed] objectForKey:@"id"]}];
}
- (void)loadOfflineStories {
@ -908,11 +909,11 @@
[storiesCollection.searchQuery stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]];
}
[self cancelRequests];
// [self cancelRequests];
NSURLSessionDataTask *request = [manager GET:theFeedDetailURL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
[self finishedLoadingFeed:responseObject withResponse:task.response];
[appDelegate.networkManager GET:theFeedDetailURL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
[self finishedLoadingFeed:responseObject withResponse:task.response feedPage:storiesCollection.feedPage feedId:nil];
if (callback) {
callback();
}
@ -935,7 +936,7 @@
#pragma mark -
#pragma mark Processing Stories
- (void)finishedLoadingFeed:(NSDictionary *)results withResponse:(NSURLResponse *)response {
- (void)finishedLoadingFeed:(NSDictionary *)results withResponse:(NSURLResponse *)response feedPage:(NSInteger)feedPage feedId:(NSString *)sentFeedId {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if (httpResponse.statusCode >= 500 || httpResponse.statusCode == 404) {
self.isOnline = NO;
@ -964,18 +965,16 @@
// [results objectForKey:@"message"]) {
// [self informError:nil details:[results objectForKey:@"message"]];
// }
id feedId = [results objectForKey:@"feed_id"];
NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId];
NSString *receivedFeedId = [NSString stringWithFormat:@"%@", [results objectForKey:@"feed_id"]];
// Ignoring below during AFNetworking 3.0 migration because we don't know the feed id anymore.
// if (!(storiesCollection.isRiverView ||
// storiesCollection.isSavedView ||
// storiesCollection.isReadView ||
// storiesCollection.isSocialView ||
// storiesCollection.isSocialRiverView)
// && request.tag != [feedId intValue]) {
// return;
// }
if (!(storiesCollection.isRiverView ||
storiesCollection.isSavedView ||
storiesCollection.isReadView ||
storiesCollection.isSocialView ||
storiesCollection.isSocialRiverView)
&& receivedFeedId != sentFeedId) {
return;
}
if (storiesCollection.isSocialView ||
storiesCollection.isSocialRiverView ||
storiesCollection.isSavedView ||
@ -999,7 +998,7 @@
[storiesCollection.activeClassifiers setObject:[newClassifiers objectForKey:key] forKey:key];
}
} else if (newClassifiers) {
[storiesCollection.activeClassifiers setObject:newClassifiers forKey:feedIdStr];
[storiesCollection.activeClassifiers setObject:newClassifiers forKey:receivedFeedId];
}
storiesCollection.activePopularAuthors = [results objectForKey:@"feed_authors"];
storiesCollection.activePopularTags = [results objectForKey:@"feed_tags"];
@ -1790,7 +1789,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
NSString *direction = older ? @"older" : @"newest";
[params setObject:direction forKey:@"direction"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionTask *task, id responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionTask *task, id responseObject) {
[appDelegate markFeedReadInCache:feedIds cutoffTimestamp:cutoffTimestamp older:older];
// is there a better way to refresh the detail view?
[self reloadStories];
@ -1911,7 +1910,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[params setObject:newTitle forKey:@"feed_title"];
}
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate reloadFeedsView:YES];
if (storiesCollection.isRiverView) {
[appDelegate renameFolder:newTitle];
@ -1942,7 +1941,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[params setObject:[storiesCollection.activeFeed objectForKey:@"id"] forKey:@"feed_id"];
[params setObject:[appDelegate extractFolderName:storiesCollection.activeFolder] forKey:@"in_folder"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate reloadFeedsView:YES];
[appDelegate.navigationController
popToViewController:[appDelegate.navigationController.viewControllers
@ -1968,7 +1967,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
extractParentFolderName:storiesCollection.activeFolder]]
forKey:@"in_folder"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate reloadFeedsView:YES];
[appDelegate.navigationController
popToViewController:[appDelegate.navigationController.viewControllers
@ -1993,7 +1992,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
NSString *urlString = [NSString stringWithFormat:@"%@/reader/save_feed_chooser", self.appDelegate.url];
[params setObject:activeIdentifiers forKey:@"approved_feeds"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self.appDelegate reloadFeedsView:YES];
[self.appDelegate.navigationController popToViewController:[appDelegate.navigationController.viewControllers objectAtIndex:0]
animated:YES];
@ -2031,7 +2030,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
[params setObject:feedIdentifier forKey:@"feed_id"];
}
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
int code = [[responseObject valueForKey:@"code"] intValue];
@ -2208,11 +2207,11 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
stringWithFormat:@"%@/reader/refresh_feed/%@",
self.appDelegate.url,
[storiesCollection.activeFeed objectForKey:@"id"]];
[self cancelRequests];
[manager GET:theFeedDetailURL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
// [self cancelRequests];
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
[self renderStories:[responseObject objectForKey:@"stories"]];
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Fail: %@", request);
NSLog(@"Fail: %@", error);
[self informError:[operation error]];
[self fetchFeedDetail:1 withCallback:nil];
}];
@ -2241,7 +2240,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
self.appDelegate.url,
feedIdsQuery];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self saveAndDrawFavicons:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailed:error];

View file

@ -225,7 +225,7 @@
NSString *urlString = [NSString stringWithFormat:@"%@/reader/login_as?user=%@",
self.appDelegate.url, username];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"Login as %@ successful", username);
[MBProgressHUD hideHUDForView:self.view animated:YES];
[appDelegate reloadFeedsView:YES];

View file

@ -115,7 +115,7 @@
- (void)connectToSocial {
NSString *urlString = [NSString stringWithFormat:@"%@/social/load_user_friends",
self.appDelegate.url];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishConnectFromSocial:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailed:error];
@ -186,9 +186,7 @@
- (IBAction)toggleAutoFollowFriends:(id)sender {
UISwitch *button = (UISwitch *)sender;
NSURL *urlString = [NSURL URLWithString:
[NSString stringWithFormat:@"%@/profile/set_preference",
self.appDelegate.url]];
NSURL *urlString = [NSString stringWithFormat:@"%@/profile/set_preference", self.appDelegate.url];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
if (button.on) {
@ -197,7 +195,7 @@
[params setObject:@"true" forKey:@"autofollow_friends"];
}
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishToggleAutoFollowFriends:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailed:error];

View file

@ -116,7 +116,7 @@
[params setObject:@"social:popular" forKey:@"user_id"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishAddSite:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self informError:error];
@ -132,7 +132,7 @@
[params setObject:@"true" forKey:@"auto_active"];
[params setObject:@"true" forKey:@"skip_fetch"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishAddSite:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self informError:error];

View file

@ -122,7 +122,7 @@
}
[params setObject:categories forKey:@"category"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self informError:error];
@ -156,7 +156,7 @@
self.appDelegate.url];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:@"true" forKey:@"auto_active"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishImportFromGoogleReader:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self importFromGoogleReaderFailed:error];
@ -235,7 +235,7 @@
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:siteUrl forKey:@"url"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self informError:error];

View file

@ -118,7 +118,7 @@
NSString *urlString = [NSString stringWithFormat:@"%@/social/find_friends?query=%@&limit=10",
self.appDelegate.url,
query];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self requestFinished:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self informError:error];
@ -128,7 +128,7 @@
- (void)loadSuggestedFriendsList {
NSString *urlString = [NSString stringWithFormat:@"%@/social/load_user_friends",
self.appDelegate.url];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self loadSuggestedFriendsListFinished:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self informError:error];

View file

@ -207,7 +207,7 @@
[params setObject:@"login" forKey:@"submit"];
[params setObject:@"1" forKey:@"api"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
int code = [[responseObject valueForKey:@"code"] intValue];
@ -252,7 +252,7 @@
[params setObject:@"login" forKey:@"submit"];
[params setObject:@"1" forKey:@"api"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
int code = [[responseObject valueForKey:@"code"] intValue];

View file

@ -145,7 +145,7 @@
[params setObject:fromFolder forKey:@"in_folder"];
[params setObject:toFolder forKey:@"to_folder"];
[params setObject:[appDelegate.storiesCollection.activeFeed objectForKey:@"id"] forKey:@"feed_id"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self requestFinished:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailed:error];
@ -184,7 +184,7 @@
[params setObject:fromFolder forKey:@"in_folder"];
[params setObject:toFolder forKey:@"to_folder"];
[params setObject:folderName forKey:@"folder_name"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishMoveFolder:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailed:error];

View file

@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#import <SafariServices/SafariServices.h>
#import "NewsBlurAppDelegate.h"
@class NewsBlurAppDelegate;

View file

@ -1287,7 +1287,7 @@
NSLog(@"Logging out...");
NSString *urlString = [NSString stringWithFormat:@"%@/reader/logout?api=1",
self.url];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self showLogin];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
@ -1325,7 +1325,7 @@
- (void)refreshUserProfile:(void(^)())callback {
NSString *urlString = [NSString stringWithFormat:@"%@/social/load_user_profile",
self.url];
[manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[appDelegate.networkManager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
self.dictUserProfile = [responseObject objectForKey:@"user_profile"];
self.dictSocialServices = [responseObject objectForKey:@"services"];
callback();
@ -3389,7 +3389,7 @@
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:[hashes JSONRepresentation] forKey:@"feeds_stories"];
[manager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"Completed clearing %@ hashes", completedHashesStr);
[db executeUpdate:[NSString stringWithFormat:@"DELETE FROM queued_read_hashes "
"WHERE story_hash in (\"%@\")", completedHashesStr]];

View file

@ -1380,7 +1380,7 @@ heightForHeaderInSection:(NSInteger)section {
forKey:@"cutoff_timestamp"];
}
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishMarkAllAsRead:responseObject];
[self finishMarkAllAsRead:params];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailedMarkStoryRead:error withParams:params];
}];
@ -1401,14 +1401,13 @@ heightForHeaderInSection:(NSInteger)section {
NSString *urlString = [NSString stringWithFormat:@"%@/reader/mark_all_as_read",
self.appDelegate.url];
NSURL *url = [NSURL URLWithString:urlString];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:[NSNumber numberWithInteger:days]
forKey:@"days"];
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishMarkAllAsRead:responseObject];
[self finishMarkAllAsRead:params];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailedMarkStoryRead:error withParams:params];
}];
@ -1426,15 +1425,14 @@ heightForHeaderInSection:(NSInteger)section {
NSDictionary *feedsStories = [appDelegate markVisibleStoriesRead];
NSString *urlString = [NSString stringWithFormat:@"%@/reader/mark_feed_stories_as_read",
self.appDelegate.url];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:[feedsStories JSONRepresentation] forKey:@"feeds_stories"];
[request setDelegate:self];
[request setUserInfo:@{@"stories": feedsStories}];
[request setDidFinishSelector:@selector(finishMarkAllAsRead:)];
[request setDidFailSelector:@selector(requestFailedMarkStoryRead:)];
[request startAsynchronous];
[appDelegate.networkManager POST:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self finishMarkAllAsRead:params];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self requestFailedMarkStoryRead:error withParams:params];
}];
}
- (void)requestFailedMarkStoryRead:(NSError *)error withParams:(NSDictionary *)params {
@ -1447,6 +1445,7 @@ heightForHeaderInSection:(NSInteger)section {
}
- (void)finishMarkAllAsRead:(NSDictionary *)params {
// This seems fishy post-ASI rewrite. This needs to know about a cutoff timestamp which it is never given.
self.isOffline = NO;
if ([[params objectForKey:@"cutoff_timestamp"] integerValue]) {

View file

@ -104,10 +104,6 @@
- (void)toggleStorySaved;
- (BOOL)toggleStorySaved:(NSDictionary *)story;
- (void)syncStoryAsSaved:(NSDictionary *)story;
- (void)finishMarkAsSaved:(ASIFormDataRequest *)request;
- (void)failedMarkAsSaved:(ASIFormDataRequest *)request;
- (void)syncStoryAsUnsaved:(NSDictionary *)story;
- (void)finishMarkAsUnsaved:(ASIFormDataRequest *)request;
- (void)failedMarkAsUnsaved:(ASIFormDataRequest *)request;
@end