зеркало из 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;
|
||||
|
||||
- (instancetype)initForRoom:(NCRoom *)room;
|
||||
- (void)stopChat;
|
||||
- (void)resumeChat;
|
||||
- (void)leaveChat;
|
||||
|
||||
@end
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef enum NCChatMessageAction {
|
|||
@property (nonatomic, assign) BOOL leftChatWithVisibleChatVC;
|
||||
@property (nonatomic, assign) BOOL offlineMode;
|
||||
@property (nonatomic, assign) BOOL hasStoredHistory;
|
||||
@property (nonatomic, assign) BOOL hasStopped;
|
||||
@property (nonatomic, assign) NSInteger lastReadMessage;
|
||||
@property (nonatomic, strong) NCChatMessage *unreadMessagesSeparator;
|
||||
@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
|
||||
{
|
||||
[_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
|
||||
|
||||
- (void)setTitleView
|
||||
|
@ -771,24 +806,6 @@ typedef enum NCChatMessageAction {
|
|||
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
|
||||
|
||||
- (void)didUpdateRoom:(NSNotification *)notification
|
||||
|
@ -822,6 +839,10 @@ typedef enum NCChatMessageAction {
|
|||
_hasJoinedRoom = YES;
|
||||
[self checkRoomControlsAvailability];
|
||||
|
||||
if (_hasStopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_leftChatWithVisibleChatVC && _hasReceiveInitialHistory) {
|
||||
_leftChatWithVisibleChatVC = NO;
|
||||
[_chatController startReceivingNewChatMessages];
|
||||
|
@ -1372,6 +1393,7 @@ typedef enum NCChatMessageAction {
|
|||
_messages = [[NSMutableDictionary alloc] init];
|
||||
_dateSections = [[NSMutableArray alloc] init];
|
||||
_hasReceiveInitialHistory = NO;
|
||||
_hasRequestedInitialHistory = NO;
|
||||
_hasReceiveNewMessages = NO;
|
||||
_unreadMessagesSeparatorIP = nil;
|
||||
[self hideNewMessagesView];
|
||||
|
|
|
@ -419,6 +419,9 @@ NSString * const NCRoomsManagerDidReceiveChatMessagesNotification = @"ChatMess
|
|||
extSignalingController.currentRoom = nil;
|
||||
}
|
||||
}
|
||||
if ([_chatViewController.room.token isEqualToString:room.token]) {
|
||||
[_chatViewController stopChat];
|
||||
}
|
||||
[[NCUserInterfaceController sharedInstance] presentCallViewController:_callViewController];
|
||||
[self joinRoom:room.token forCall:YES];
|
||||
} else {
|
||||
|
@ -478,6 +481,10 @@ NSString * const NCRoomsManagerDidReceiveChatMessagesNotification = @"ChatMess
|
|||
}
|
||||
[[CallKitManager sharedInstance] endCurrentCall];
|
||||
[self leaveRoom:room.token];
|
||||
|
||||
if ([_chatViewController.room.token isEqualToString:room.token]) {
|
||||
[_chatViewController resumeChat];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - CallViewControllerDelegate
|
||||
|
|
Загрузка…
Ссылка в новой задаче