Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
version 0.0.46 (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassan Shahbazi authored Apr 29, 2020
1 parent 4d2807b commit 38a9768
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ -(void) setSessionManager:(NINSessionManager*)sessionManager {

-(void) newMessageWasAddedAtIndex:(NSInteger)index {
runOnMainThread(^{
if ([self.tableView numberOfRowsInSection:0] >= [self.dataSource numberOfMessagesForChatView:self]) { return; }

[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
Expand All @@ -168,6 +170,8 @@ -(void) newMessageWasAddedAtIndex:(NSInteger)index {

-(void) messageWasRemovedAtIndex:(NSInteger)index {
runOnMainThread(^{
if ([self.tableView numberOfRowsInSection:0] <= [self.dataSource numberOfMessagesForChatView:self]) { return; }

[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

@import CoreServices;
@import MobileCoreServices;
@import AVFoundation;
@import AVKit;
@import Photos;
Expand Down Expand Up @@ -391,13 +392,15 @@ -(void) listenToWebRTCSignaling {

// Show the video view
[weakSelf adjustConstraintsForSize:weakSelf.view.bounds.size animate:YES];
[self resizeLocalVideoView];
[weakSelf resizeLocalVideoView];
[weakSelf stopIdleTimer:YES];
}];
} else if ([note.userInfo[@"messageType"] isEqualToString:kNINMessageTypeWebRTCHangup]) {
NSLog(@"Got WebRTC hang-up - closing the video call.");

// Disconnect
[weakSelf disconnectWebRTC];
[weakSelf stopIdleTimer:NO];

// Close the video view
[weakSelf adjustConstraintsForSize:weakSelf.view.bounds.size animate:YES];
Expand Down Expand Up @@ -861,6 +864,14 @@ -(void) keyboardWillHide:(NSNotification *)notification {
[self.sessionManager setIsWriting:NO completion:^(NSError* error) {}];
}

#pragma mark - Helper

/// To prevent screen-saver during a video call
/// https://github.com/somia/mobile/issues/204
- (void) stopIdleTimer:(BOOL )stop {
[UIApplication sharedApplication].idleTimerDisabled = stop;
}

#pragma mark - Lifecycle etc.

-(void) viewWillAppear:(BOOL)animated {
Expand Down Expand Up @@ -981,7 +992,7 @@ -(void) viewDidLoad {
NSNumber* index = note.userInfo[@"index"];
if ([note.userInfo[@"action"] isEqualToString:@"insert"]) {
[weakSelf.chatView newMessageWasAddedAtIndex:index.integerValue];
} else {
} else if ([note.userInfo[@"action"] isEqualToString:@"remove"]) {
[weakSelf.chatView messageWasRemovedAtIndex:index.integerValue];
}

Expand Down

0 comments on commit 38a9768

Please sign in to comment.