mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fixes #553
This commit is contained in:
parent
4833487e94
commit
585079de21
|
@ -103,6 +103,8 @@ typedef enum : NSUInteger {
|
|||
|
||||
@property NSUInteger page;
|
||||
|
||||
@property BOOL isVisible;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MessagesViewController
|
||||
|
@ -143,11 +145,12 @@ typedef enum : NSUInteger {
|
|||
else if(![self isTextSecureReachable] ){
|
||||
[self inputToolbar].hidden= YES; // only RedPhone
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"btnPhone--white"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(callAction)];;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
_isVisible = NO;
|
||||
[self.navigationController.navigationBar setTranslucent:NO];
|
||||
|
||||
_showFingerprintDisplay = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showFingerprint)];
|
||||
|
@ -185,6 +188,7 @@ typedef enum : NSUInteger {
|
|||
|
||||
[self updateRangeOptionsForPage:self.page];
|
||||
|
||||
[self.uiDatabaseConnection beginLongLivedReadTransaction];
|
||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||
[self.messageMappings updateWithTransaction:transaction];
|
||||
}];
|
||||
|
@ -217,6 +221,7 @@ typedef enum : NSUInteger {
|
|||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self.collectionView reloadData];
|
||||
NSInteger numberOfMessages = (NSInteger)[self.messageMappings numberOfItemsInGroup:self.thread.uniqueId];
|
||||
|
||||
if (numberOfMessages > 0) {
|
||||
|
@ -237,6 +242,7 @@ typedef enum : NSUInteger {
|
|||
- (void)viewDidAppear:(BOOL)animated{
|
||||
[super viewDidAppear:animated];
|
||||
[self startReadTimer];
|
||||
_isVisible = YES;
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated{
|
||||
|
@ -274,6 +280,10 @@ typedef enum : NSUInteger {
|
|||
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated{
|
||||
_isVisible = NO;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
@ -449,9 +459,6 @@ typedef enum : NSUInteger {
|
|||
return [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:contactId];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
-(void)callAction
|
||||
{
|
||||
if ([self isRedPhoneReachable]) {
|
||||
|
@ -1251,24 +1258,44 @@ typedef enum : NSUInteger {
|
|||
[self initializeToolbars];
|
||||
}];
|
||||
}
|
||||
// Process the notification(s),
|
||||
// and get the change-set(s) as applies to my view and mappings configuration.
|
||||
NSArray *notifications = [self.uiDatabaseConnection beginLongLivedReadTransaction];
|
||||
NSArray *messageRowChanges = nil;
|
||||
|
||||
[[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] getSectionChanges:nil
|
||||
NSArray *notifications = [self.uiDatabaseConnection beginLongLivedReadTransaction];
|
||||
|
||||
if ( ![[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] hasChangesForNotifications:notifications])
|
||||
{
|
||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){
|
||||
[self.messageMappings updateWithTransaction:transaction];
|
||||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isVisible)
|
||||
{
|
||||
// Since we moved our databaseConnection to a new commit,
|
||||
// we need to update the mappings too.
|
||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){
|
||||
[self.messageMappings updateWithTransaction:transaction];
|
||||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *messageRowChanges = nil;
|
||||
NSArray *sectionChanges = nil;
|
||||
|
||||
|
||||
[[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] getSectionChanges:§ionChanges
|
||||
rowChanges:&messageRowChanges
|
||||
forNotifications:notifications
|
||||
withMappings:self.messageMappings];
|
||||
|
||||
__block BOOL scrollToBottom = NO;
|
||||
|
||||
if (!messageRowChanges) {
|
||||
if ([sectionChanges count] == 0 & [messageRowChanges count] == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[self.collectionView performBatchUpdates:^{
|
||||
|
||||
for (YapDatabaseViewRowChange *rowChange in messageRowChanges)
|
||||
{
|
||||
switch (rowChange.type)
|
||||
|
|
Loading…
Reference in a new issue