summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r--Juick/ViewControllers/DiscoverViewController.m26
-rw-r--r--Juick/ViewControllers/MessagesViewController.m20
-rw-r--r--Juick/ViewControllers/NewPostViewController.m3
3 files changed, 25 insertions, 24 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];
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m
index 823d838..8e4835b 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -76,25 +76,7 @@
self.tableView.estimatedRowHeight = 500.0f;
self.messages = [NSMutableArray array];
self.refreshControl = [UIRefreshControl new];
- [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
- if ([User isAuthenticated]) {
- [User checkIsValid:^(BOOL success) {
- if (success) {
- if ([self.path length] == 0) {
- self.path = [APIClient feedUrl];
- }
- [self refreshData:NO];
- } else {
- [User throwUnableToLogin:self];
- }
- }];
-
- } else {
- if ([self.path length] == 0) {
- self.path = [APIClient messagesUrl];
- }
- [self refreshData:NO];
- }
+ [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
}
- (void) composePressed {
diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m
index 8a9bc0e..143dd96 100644
--- a/Juick/ViewControllers/NewPostViewController.m
+++ b/Juick/ViewControllers/NewPostViewController.m
@@ -35,8 +35,7 @@
}
self.navigationController.visibleViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self action:@selector(cancelCompose)];
- self.navigationController.visibleViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
- target:self action:@selector(doneCompose)];
+ self.navigationController.visibleViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Send" style:UIBarButtonItemStyleDone target:self action:@selector(doneCompose)];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
[self.textView becomeFirstResponder];