зеркало из https://github.com/nextcloud/talk-ios.git
Leave chat correctly when leaving or deleting room from room info view.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
d7e1e7738b
Коммит
d7d2107306
|
@ -13,5 +13,6 @@
|
|||
@interface NCChatViewController : SLKTextViewController
|
||||
|
||||
- (instancetype)initForRoom:(NCRoom *)room;
|
||||
- (void)leaveChat;
|
||||
|
||||
@end
|
||||
|
|
|
@ -204,11 +204,16 @@
|
|||
|
||||
// Leave chat when the view controller has been removed from its parent view.
|
||||
if (self.isMovingFromParentViewController) {
|
||||
[_lobbyCheckTimer invalidate];
|
||||
[[NCRoomsManager sharedInstance] leaveChatInRoom:_room.token];
|
||||
[self leaveChat];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)leaveChat
|
||||
{
|
||||
[_lobbyCheckTimer invalidate];
|
||||
[[NCRoomsManager sharedInstance] leaveChatInRoom:_room.token];
|
||||
}
|
||||
|
||||
#pragma mark - Configuration
|
||||
|
||||
- (void)setTitleView
|
||||
|
@ -369,7 +374,7 @@
|
|||
|
||||
- (void)titleButtonPressed:(id)sender
|
||||
{
|
||||
RoomInfoTableViewController *roomInfoVC = [[RoomInfoTableViewController alloc] initForRoom:_room];
|
||||
RoomInfoTableViewController *roomInfoVC = [[RoomInfoTableViewController alloc] initForRoom:_room fromChatViewController:self];
|
||||
[self.navigationController pushViewController:roomInfoVC animated:YES];
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "NCRoom.h"
|
||||
#import "NCChatViewController.h"
|
||||
|
||||
@interface RoomInfoTableViewController : UITableViewController
|
||||
|
||||
- (instancetype)initForRoom:(NCRoom *)room;
|
||||
- (instancetype)initForRoom:(NCRoom *)room fromChatViewController:(NCChatViewController *)chatViewController;
|
||||
|
||||
@end
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef enum ModificationError {
|
|||
@interface RoomInfoTableViewController () <UITextFieldDelegate, UIGestureRecognizerDelegate>
|
||||
|
||||
@property (nonatomic, strong) NCRoom *room;
|
||||
@property (nonatomic, strong) NCChatViewController *chatViewController;
|
||||
@property (nonatomic, strong) NSString *roomName;
|
||||
@property (nonatomic, strong) NSMutableArray *roomParticipants;
|
||||
@property (nonatomic, strong) UITextField *roomNameTextField;
|
||||
|
@ -87,10 +88,16 @@ typedef enum ModificationError {
|
|||
@implementation RoomInfoTableViewController
|
||||
|
||||
- (instancetype)initForRoom:(NCRoom *)room
|
||||
{
|
||||
return [self initForRoom:room fromChatViewController:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initForRoom:(NCRoom *)room fromChatViewController:(NCChatViewController *)chatViewController
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_room = room;
|
||||
_chatViewController = chatViewController;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -621,6 +628,9 @@ typedef enum ModificationError {
|
|||
{
|
||||
[[NCAPIController sharedInstance] removeSelfFromRoom:_room.token withCompletionBlock:^(NSInteger errorCode, NSError *error) {
|
||||
if (!error) {
|
||||
if (_chatViewController) {
|
||||
[_chatViewController leaveChat];
|
||||
}
|
||||
[[NCUserInterfaceController sharedInstance] presentConversationsList];
|
||||
} else if (errorCode == 400) {
|
||||
[self showRoomModificationError:kModificationErrorLeaveModeration];
|
||||
|
@ -635,6 +645,9 @@ typedef enum ModificationError {
|
|||
{
|
||||
[[NCAPIController sharedInstance] deleteRoom:_room.token withCompletionBlock:^(NSError *error) {
|
||||
if (!error) {
|
||||
if (_chatViewController) {
|
||||
[_chatViewController leaveChat];
|
||||
}
|
||||
[[NCUserInterfaceController sharedInstance] presentConversationsList];
|
||||
} else {
|
||||
NSLog(@"Error deleting the room: %@", error.description);
|
||||
|
|
Загрузка…
Ссылка в новой задаче