summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/NewPostViewController.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-10-01 17:29:46 +0300
committerGravatar Vitaly Takmazov2019-10-01 22:14:59 +0300
commitdbab6ab54c40a016f75e75a4143576c3fa41c3e0 (patch)
tree6fd5e68ec76c249fcaa07219c53ccab2f4c98fd5 /Juick/ViewControllers/NewPostViewController.m
parentaeb513ed5c165e355c9c378efde7445f597d0380 (diff)
Drop AFNetworking and SSKeychain
Diffstat (limited to 'Juick/ViewControllers/NewPostViewController.m')
-rw-r--r--Juick/ViewControllers/NewPostViewController.m29
1 files changed, 22 insertions, 7 deletions
diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m
index 65172f1..afa14a9 100644
--- a/Juick/ViewControllers/NewPostViewController.m
+++ b/Juick/ViewControllers/NewPostViewController.m
@@ -10,6 +10,10 @@
#import "MessagesViewController.h"
#import "QuoteView.h"
#import "APIClient.h"
+#import "AppDelegate.h"
+
+NSString * const NewMessageNotificationName = @"NewMessage";
+NSString * const ReplyPostedNotificationName = @"ReplyPosted";
@interface NewPostViewController ()
@@ -42,17 +46,28 @@
- (IBAction)sendAction:(id)sender {
self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;
if (_replyTo == nil) {
+ self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
[[APIClient sharedClient] postMessage:self.textView.text result:^(Message *msg, NSError *err) {
- self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
- [self.navigationController popViewControllerAnimated:YES];
- [(MessagesViewController *)self.navigationController.visibleViewController setShouldScrollToUnreadOnRefresh:YES];
+ if (!err) {
+ [self dismissViewControllerAnimated:YES completion:^{
+ [[NSNotificationCenter defaultCenter] postNotificationName:NewMessageNotificationName object:msg];
+ }];
+ } else {
+ self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
+ // TODO: display error
+ }
}];
} else {
+ self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;
[[APIClient sharedClient] postReplyToThread:_replyTo.mid inReplyTo:_replyTo.rid text:self.textView.text result:^(Message *msg, NSError *err) {
- self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
- [self.navigationController popViewControllerAnimated:YES];
- [(MessagesViewController *)self.navigationController.visibleViewController setShouldScrollToUnreadOnRefresh:YES];
- [(MessagesViewController *)self.navigationController.visibleViewController refreshData];
+ if (!err) {
+ [self dismissViewControllerAnimated:YES completion:^{
+ [[NSNotificationCenter defaultCenter] postNotificationName:ReplyPostedNotificationName object:msg];
+ }];
+ } else {
+ self.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
+ // TODO: display error
+ }
}];
}
}