Skip to content

Commit

Permalink
Show login modal box when not signed in.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matsimitsu committed Oct 15, 2011
1 parent 0730cb2 commit 0f1099c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Classes/Controllers/LibraryViewController.m
Expand Up @@ -2,7 +2,7 @@

#import "Show.h"
#import "ShowDetailsViewController.h"

#import "AuthenticationViewController.h"
#import "Trakt.h"
#import "HTTPDownload.h"

Expand All @@ -13,6 +13,7 @@ @implementation LibraryViewController

- (void)viewDidLoad {
[super viewDidLoad];
[self checkAuth];

self.feedSelector = @"library:";
self.cachedFeedProperty = @"library";
Expand All @@ -27,6 +28,7 @@ - (void)viewDidLoad {
}

- (void)reloadTableViewData:(NSArray *)data {

NSMutableArray *groupedShows = [NSMutableArray array];
NSMutableArray *titles = [NSMutableArray array];

Expand Down
2 changes: 1 addition & 1 deletion Classes/Controllers/RootViewController.h
Expand Up @@ -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
13 changes: 12 additions & 1 deletion 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;
Expand All @@ -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) {
Expand Down

0 comments on commit 0f1099c

Please sign in to comment.