summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/DiscoverViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-10 11:52:54 +0300
committerGravatar Vitaly Takmazov2017-12-10 11:52:54 +0300
commit38d16e9d26b4f8653063ef2c572ccfc803ab165b (patch)
treec0e3bc1bb760f38150850f5e451bea77fa5a8373 /Juick/ViewControllers/DiscoverViewController.m
parent8a9a7fb25405c3662ae9b3b58263e9088baa7082 (diff)
fix layout
Diffstat (limited to 'Juick/ViewControllers/DiscoverViewController.m')
-rw-r--r--Juick/ViewControllers/DiscoverViewController.m26
1 files changed, 23 insertions, 3 deletions
diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m
index 2a109d4..26ec710 100644
--- a/Juick/ViewControllers/DiscoverViewController.m
+++ b/Juick/ViewControllers/DiscoverViewController.m
@@ -23,10 +23,25 @@ AppDelegate *appDelegate;
-(void) viewDidLoad {
[super viewDidLoad];
[self.navigationController.navigationBar setPrefersLargeTitles:YES];
- if ([self.path isEqualToString:[APIClient feedUrl]]) {
- [self setTitle:@"My feed"];
+ if ([User isAuthenticated]) {
+ [User checkIsValid:^(BOOL success) {
+ if (success) {
+ if ([self.path length] == 0) {
+ self.path = [APIClient feedUrl];
+ [self setTitle:@"My feed"];
+ }
+ [self refreshData:NO];
+ } else {
+ [User throwUnableToLogin:self];
+ }
+ }];
+
} else {
- [self setTitle:@"Discover"];
+ if ([self.path length] == 0) {
+ self.path = [APIClient messagesUrl];
+ [self setTitle:@"Discover"];
+ }
+ [self refreshData:NO];
}
appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
if (appDelegate.pushedThread != nil) {
@@ -43,9 +58,11 @@ AppDelegate *appDelegate;
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqual: @"threadViewSegue"]) {
NSNumber *mid;
+ BOOL scrollToEnd = NO;
if (appDelegate.pushedThread != nil) {
mid = appDelegate.pushedThread;
appDelegate.pushedThread = nil;
+ scrollToEnd = YES;
} else {
Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row];
mid = msg.mid;
@@ -53,12 +70,14 @@ AppDelegate *appDelegate;
ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController;
[threadVC setPath:[APIClient threadUrl]];
[threadVC setParams:[@{@"mid": mid } mutableCopy]];
+ [threadVC refreshData:scrollToEnd];
}
}
- (IBAction)filterAction:(id)sender {
UIAlertController *filterAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[filterAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[filterAlert addAction:[UIAlertAction actionWithTitle:@"My feed" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ [self setTitle:@"My feed"];
self.path = [APIClient feedUrl];
self.params = nil;
[self.messages removeAllObjects];
@@ -66,6 +85,7 @@ AppDelegate *appDelegate;
[self refreshData:NO];
}]];
[filterAlert addAction:[UIAlertAction actionWithTitle:@"Discover" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ [self setTitle:@"Discover"];
self.path = [APIClient messagesUrl];
self.params = nil;
[self.messages removeAllObjects];