diff options
author | Vitaly Takmazov | 2019-03-21 19:28:15 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-21 19:28:15 +0300 |
commit | e6fec9707f61b5d521bf1a2e6a85998f2466bdfa (patch) | |
tree | cef8da0d57deac351ee98efc6c875952486e04eb /Juick/ViewControllers/DiscoverViewController.m | |
parent | 0e3fc6807af7b85ba9aa37763b311cf9d8443822 (diff) |
Update icons
Diffstat (limited to 'Juick/ViewControllers/DiscoverViewController.m')
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m deleted file mode 100644 index 94e1d16..0000000 --- a/Juick/ViewControllers/DiscoverViewController.m +++ /dev/null @@ -1,159 +0,0 @@ -// -// DiscoverViewController.m -// Juick -// -// Created by Vitaly Takmazov on 03/12/2017. -// Copyright © 2017 com.juick. All rights reserved. -// - -#import "DiscoverViewController.h" -#import "ThreadViewController.h" -#import "BlogViewController.h" -#import "MessageCell.h" -#import "APIClient.h" -#import "AppDelegate.h" -#import "ColorScheme.h" - -@interface DiscoverViewController () - -@property NSString *selectedUser; -@end - -@implementation DiscoverViewController - --(void) viewDidLoad { - self.messagesDelegate = self; - if ([[APIClient sharedClient] isAuthenticated]) { - [[APIClient sharedClient] authenticate:^(User *user, NSError *error) { - if (user) { - if ([self.path length] == 0) { - self.path = [APIClient feedUrl]; - [self.tabBarItem setTitle:@"My feed"]; - self.navigationController.visibleViewController.navigationItem.title = @"My feed"; - } - [self setShouldScrollToBottomOnRefresh:NO]; - [self refreshData]; - } else { - [User throwUnableToLogin:self error:error]; - } - }]; - - } else { - if ([self.path length] == 0) { - self.path = [APIClient messagesUrl]; - [self.tabBarItem setTitle:@"Discover"]; - self.navigationController.visibleViewController.navigationItem.title = @"Discover"; - } - [self setShouldScrollToBottomOnRefresh:NO]; - [self refreshData]; - } - [super viewDidLoad]; -} - --(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSString * cellIdentifier = @"messageCell"; - MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; - [self performSegueWithIdentifier:@"threadViewSegue" sender:cell]; -} -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (!self.dataLoading) { - MessageCell *cell = (MessageCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath]; - cell.delegate = self; - return cell; - } else { - return [super tableView:tableView cellForRowAtIndexPath:indexPath]; - } -} - --(void)avatarClicked:(NSString *)uname { - self.selectedUser = uname; - [self performSegueWithIdentifier:@"profileSegue" sender:self]; -} - --(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - if ([segue.identifier isEqual: @"threadViewSegue"]) { - NSNumber *mid; - BOOL scrollToEnd = NO; - if ([AppDelegate shared].pushedThread != nil) { - mid = [[AppDelegate shared].pushedThread copy]; - [AppDelegate shared].pushedThread = nil; - [AppDelegate shared].pushedUname = nil; - scrollToEnd = YES; - } else { - Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; - mid = msg.mid; - } - if ([mid integerValue] > 0) { - ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController; - [threadVC setPath:[APIClient threadUrl]]; - [threadVC setParams:@{@"mid": mid }]; - [threadVC setShouldScrollToBottomOnRefresh:scrollToEnd]; - } - } - if ([segue.identifier isEqual: @"profileSegue"]) { - BlogViewController *blogVC = (BlogViewController *)segue.destinationViewController; - [blogVC setUname:self.selectedUser]; - [blogVC setTitle:self.selectedUser]; - blogVC.path = [NSString stringWithFormat:@"/messages?uname=%@", self.selectedUser]; - [blogVC setShouldScrollToBottomOnRefresh:NO]; - } -} -- (IBAction)filterAction:(id)sender { - if (![[APIClient sharedClient] isAuthenticated]) { - [self.navigationController performSegueWithIdentifier:@"loginSegue" sender:self.navigationController]; - return; - } - 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.path = [APIClient feedUrl]; - [self.tabBarItem setTitle:@"My feed"]; - self.navigationController.visibleViewController.navigationItem.title = @"My feed"; - self.params = nil; - [self.messages removeAllObjects]; - [self.tableView reloadData]; - [self setShouldScrollToBottomOnRefresh:NO]; - }]]; - [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discover" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - self.path = [APIClient messagesUrl]; - [self.tabBarItem setTitle:@"Discover"]; - self.navigationController.visibleViewController.navigationItem.title = @"Discover"; - self.params = nil; - [self.messages removeAllObjects]; - [self.tableView reloadData]; - [self setShouldScrollToBottomOnRefresh:NO]; - }]]; - [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discussions" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - self.path = [APIClient discussionsUrl]; - [self.tabBarItem setTitle:@"Discussions"]; - self.navigationController.visibleViewController.navigationItem.title = @"Discussions"; - self.params = nil; - [self.messages removeAllObjects]; - [self.tableView reloadData]; - [self setShouldScrollToBottomOnRefresh:NO]; - }]]; - [filterAlert.view setTintColor:[ColorScheme linkColor]]; - UIPopoverPresentationController *popover = [filterAlert popoverPresentationController]; - if (popover) { - popover.sourceView = self.view; - popover.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 0, 0); - popover.permittedArrowDirections = UIPopoverArrowDirectionUp; - } - [self presentViewController:filterAlert animated:YES completion:nil]; -} - --(void) loadMore { - Message *lastMsg = [self.messages lastObject]; - if (lastMsg != nil) { - if ([self.path isEqualToString:[APIClient discussionsUrl]]) { - NSDate *msgDate = [[APIClient sharedClient].dateFormatter dateFromString:lastMsg.timestamp]; - self.params = [@{@"to" : [NSString stringWithFormat:@"%.0f", [msgDate timeIntervalSince1970] * 1000]} mutableCopy]; - } else if (![self.path isEqualToString:[APIClient threadUrl]]) { - NSNumber *lastMid = lastMsg.mid; - self.params = [@{@"before_mid":lastMid} mutableCopy]; - } - [self setShouldScrollToBottomOnRefresh:NO]; - } -} - -@end |