зеркало из https://github.com/nextcloud/talk-ios.git
Stop/Resume chat owned by rooms manager when start/end a call.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
77946f1ac3
Коммит
35861aa095
|
@ -15,6 +15,8 @@
|
||||||
@property (nonatomic, strong) NCRoom *room;
|
@property (nonatomic, strong) NCRoom *room;
|
||||||
|
|
||||||
- (instancetype)initForRoom:(NCRoom *)room;
|
- (instancetype)initForRoom:(NCRoom *)room;
|
||||||
|
- (void)stopChat;
|
||||||
|
- (void)resumeChat;
|
||||||
- (void)leaveChat;
|
- (void)leaveChat;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -65,6 +65,7 @@ typedef enum NCChatMessageAction {
|
||||||
@property (nonatomic, assign) BOOL leftChatWithVisibleChatVC;
|
@property (nonatomic, assign) BOOL leftChatWithVisibleChatVC;
|
||||||
@property (nonatomic, assign) BOOL offlineMode;
|
@property (nonatomic, assign) BOOL offlineMode;
|
||||||
@property (nonatomic, assign) BOOL hasStoredHistory;
|
@property (nonatomic, assign) BOOL hasStoredHistory;
|
||||||
|
@property (nonatomic, assign) BOOL hasStopped;
|
||||||
@property (nonatomic, assign) NSInteger lastReadMessage;
|
@property (nonatomic, assign) NSInteger lastReadMessage;
|
||||||
@property (nonatomic, strong) NCChatMessage *unreadMessagesSeparator;
|
@property (nonatomic, strong) NCChatMessage *unreadMessagesSeparator;
|
||||||
@property (nonatomic, strong) NSIndexPath *unreadMessagesSeparatorIP;
|
@property (nonatomic, strong) NSIndexPath *unreadMessagesSeparatorIP;
|
||||||
|
@ -271,6 +272,22 @@ typedef enum NCChatMessageAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)stopChat
|
||||||
|
{
|
||||||
|
_hasStopped = YES;
|
||||||
|
[_chatController stopChatController];
|
||||||
|
[self cleanChat];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)resumeChat
|
||||||
|
{
|
||||||
|
_hasStopped = NO;
|
||||||
|
if (!_hasReceiveInitialHistory && !_hasRequestedInitialHistory) {
|
||||||
|
_hasRequestedInitialHistory = YES;
|
||||||
|
[_chatController getInitialChatHistory];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)leaveChat
|
- (void)leaveChat
|
||||||
{
|
{
|
||||||
[_lobbyCheckTimer invalidate];
|
[_lobbyCheckTimer invalidate];
|
||||||
|
@ -286,6 +303,24 @@ typedef enum NCChatMessageAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - App lifecycle notifications
|
||||||
|
|
||||||
|
-(void)appDidBecomeActive:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
[self removeUnreadMessagesSeparator];
|
||||||
|
if (!_offlineMode) {
|
||||||
|
[[NCRoomsManager sharedInstance] joinRoom:_room.token];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)appWillResignActive:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
_hasReceiveNewMessages = NO;
|
||||||
|
_leftChatWithVisibleChatVC = YES;
|
||||||
|
[_chatController stopChatController];
|
||||||
|
[[NCRoomsManager sharedInstance] leaveChatInRoom:_room.token];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Configuration
|
#pragma mark - Configuration
|
||||||
|
|
||||||
- (void)setTitleView
|
- (void)setTitleView
|
||||||
|
@ -771,24 +806,6 @@ typedef enum NCChatMessageAction {
|
||||||
return [super textView:textView shouldChangeTextInRange:range replacementText:text];
|
return [super textView:textView shouldChangeTextInRange:range replacementText:text];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - App lifecycle notifications
|
|
||||||
|
|
||||||
-(void)appDidBecomeActive:(NSNotification*)notification
|
|
||||||
{
|
|
||||||
[self removeUnreadMessagesSeparator];
|
|
||||||
if (!_offlineMode) {
|
|
||||||
[[NCRoomsManager sharedInstance] joinRoom:_room.token];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)appWillResignActive:(NSNotification*)notification
|
|
||||||
{
|
|
||||||
_hasReceiveNewMessages = NO;
|
|
||||||
_leftChatWithVisibleChatVC = YES;
|
|
||||||
[_chatController stopChatController];
|
|
||||||
[[NCRoomsManager sharedInstance] leaveChatInRoom:_room.token];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Room Manager notifications
|
#pragma mark - Room Manager notifications
|
||||||
|
|
||||||
- (void)didUpdateRoom:(NSNotification *)notification
|
- (void)didUpdateRoom:(NSNotification *)notification
|
||||||
|
@ -822,6 +839,10 @@ typedef enum NCChatMessageAction {
|
||||||
_hasJoinedRoom = YES;
|
_hasJoinedRoom = YES;
|
||||||
[self checkRoomControlsAvailability];
|
[self checkRoomControlsAvailability];
|
||||||
|
|
||||||
|
if (_hasStopped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_leftChatWithVisibleChatVC && _hasReceiveInitialHistory) {
|
if (_leftChatWithVisibleChatVC && _hasReceiveInitialHistory) {
|
||||||
_leftChatWithVisibleChatVC = NO;
|
_leftChatWithVisibleChatVC = NO;
|
||||||
[_chatController startReceivingNewChatMessages];
|
[_chatController startReceivingNewChatMessages];
|
||||||
|
@ -1372,6 +1393,7 @@ typedef enum NCChatMessageAction {
|
||||||
_messages = [[NSMutableDictionary alloc] init];
|
_messages = [[NSMutableDictionary alloc] init];
|
||||||
_dateSections = [[NSMutableArray alloc] init];
|
_dateSections = [[NSMutableArray alloc] init];
|
||||||
_hasReceiveInitialHistory = NO;
|
_hasReceiveInitialHistory = NO;
|
||||||
|
_hasRequestedInitialHistory = NO;
|
||||||
_hasReceiveNewMessages = NO;
|
_hasReceiveNewMessages = NO;
|
||||||
_unreadMessagesSeparatorIP = nil;
|
_unreadMessagesSeparatorIP = nil;
|
||||||
[self hideNewMessagesView];
|
[self hideNewMessagesView];
|
||||||
|
|
|
@ -419,6 +419,9 @@ NSString * const NCRoomsManagerDidReceiveChatMessagesNotification = @"ChatMess
|
||||||
extSignalingController.currentRoom = nil;
|
extSignalingController.currentRoom = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ([_chatViewController.room.token isEqualToString:room.token]) {
|
||||||
|
[_chatViewController stopChat];
|
||||||
|
}
|
||||||
[[NCUserInterfaceController sharedInstance] presentCallViewController:_callViewController];
|
[[NCUserInterfaceController sharedInstance] presentCallViewController:_callViewController];
|
||||||
[self joinRoom:room.token forCall:YES];
|
[self joinRoom:room.token forCall:YES];
|
||||||
} else {
|
} else {
|
||||||
|
@ -478,6 +481,10 @@ NSString * const NCRoomsManagerDidReceiveChatMessagesNotification = @"ChatMess
|
||||||
}
|
}
|
||||||
[[CallKitManager sharedInstance] endCurrentCall];
|
[[CallKitManager sharedInstance] endCurrentCall];
|
||||||
[self leaveRoom:room.token];
|
[self leaveRoom:room.token];
|
||||||
|
|
||||||
|
if ([_chatViewController.room.token isEqualToString:room.token]) {
|
||||||
|
[_chatViewController resumeChat];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - CallViewControllerDelegate
|
#pragma mark - CallViewControllerDelegate
|
||||||
|
|
Загрузка…
Ссылка в новой задаче