From 0f1099c75f848332f973e37f2bd4bfb743eaa957 Mon Sep 17 00:00:00 2001 From: Robert Beekman Date: Sat, 15 Oct 2011 13:33:53 +0200 Subject: [PATCH] Show login modal box when not signed in. Not sure if this is the best way, but we can show the authentication controller when no username is found. We'd have to change the design of the authentication view, but it saves us from building a new view that will only tell you have to be signed in. --- Classes/Controllers/LibraryViewController.m | 4 +++- Classes/Controllers/RootViewController.h | 2 +- Classes/Controllers/RootViewController.m | 13 ++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Classes/Controllers/LibraryViewController.m b/Classes/Controllers/LibraryViewController.m index 4018460..8ad9266 100644 --- a/Classes/Controllers/LibraryViewController.m +++ b/Classes/Controllers/LibraryViewController.m @@ -2,7 +2,7 @@ #import "Show.h" #import "ShowDetailsViewController.h" - +#import "AuthenticationViewController.h" #import "Trakt.h" #import "HTTPDownload.h" @@ -13,6 +13,7 @@ @implementation LibraryViewController - (void)viewDidLoad { [super viewDidLoad]; + [self checkAuth]; self.feedSelector = @"library:"; self.cachedFeedProperty = @"library"; @@ -27,6 +28,7 @@ - (void)viewDidLoad { } - (void)reloadTableViewData:(NSArray *)data { + NSMutableArray *groupedShows = [NSMutableArray array]; NSMutableArray *titles = [NSMutableArray array]; diff --git a/Classes/Controllers/RootViewController.h b/Classes/Controllers/RootViewController.h index 4339618..a5034ac 100644 --- a/Classes/Controllers/RootViewController.h +++ b/Classes/Controllers/RootViewController.h @@ -7,9 +7,9 @@ @property (nonatomic, retain) NSString *feedSelector, *cachedFeedProperty; - (void)refreshData; +- (void)checkAuth; - (void)reloadTableViewData:(NSArray *)data; - (void)showRefreshDataButton; - (void)showStopRefreshDataButton; - (void)cancelRefreshData; - @end diff --git a/Classes/Controllers/RootViewController.m b/Classes/Controllers/RootViewController.m index 344c1ed..53bc15d 100644 --- a/Classes/Controllers/RootViewController.m +++ b/Classes/Controllers/RootViewController.m @@ -1,7 +1,7 @@ #import "RootViewController.h" #import "Trakt.h" #import "HTTPDownload.h" - +#import "AuthenticationViewController.h" @implementation RootViewController @synthesize feedSelector, cachedFeedProperty; @@ -26,6 +26,17 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } +- (void)checkAuth { + NSString *username = [Trakt sharedInstance].apiUser; + if([username length] == 0){ + AuthenticationViewController *controller = [AuthenticationViewController alloc]; + + [self presentModalViewController:controller animated:YES]; + + [controller release]; + } +} + - (void)refreshData { [self showStopRefreshDataButton]; [[Trakt sharedInstance] retrieveRootControllerDataStartingWith:feedSelector block:^(NSArray *data) {