|
|
@ -103,6 +103,8 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
|
|
@property NSUInteger page;
|
|
|
|
@property NSUInteger page;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property BOOL isVisible;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation MessagesViewController
|
|
|
|
@implementation MessagesViewController
|
|
|
@ -143,11 +145,12 @@ typedef enum : NSUInteger {
|
|
|
|
else if(![self isTextSecureReachable] ){
|
|
|
|
else if(![self isTextSecureReachable] ){
|
|
|
|
[self inputToolbar].hidden= YES; // only RedPhone
|
|
|
|
[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)];;
|
|
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"btnPhone--white"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(callAction)];;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
_isVisible = NO;
|
|
|
|
[self.navigationController.navigationBar setTranslucent:NO];
|
|
|
|
[self.navigationController.navigationBar setTranslucent:NO];
|
|
|
|
|
|
|
|
|
|
|
|
_showFingerprintDisplay = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showFingerprint)];
|
|
|
|
_showFingerprintDisplay = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showFingerprint)];
|
|
|
@ -185,6 +188,7 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
|
|
[self updateRangeOptionsForPage:self.page];
|
|
|
|
[self updateRangeOptionsForPage:self.page];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self.uiDatabaseConnection beginLongLivedReadTransaction];
|
|
|
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
[self.messageMappings updateWithTransaction:transaction];
|
|
|
|
[self.messageMappings updateWithTransaction:transaction];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
@ -216,7 +220,8 @@ typedef enum : NSUInteger {
|
|
|
|
-(void)viewWillAppear:(BOOL)animated
|
|
|
|
-(void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self.collectionView reloadData];
|
|
|
|
NSInteger numberOfMessages = (NSInteger)[self.messageMappings numberOfItemsInGroup:self.thread.uniqueId];
|
|
|
|
NSInteger numberOfMessages = (NSInteger)[self.messageMappings numberOfItemsInGroup:self.thread.uniqueId];
|
|
|
|
|
|
|
|
|
|
|
|
if (numberOfMessages > 0) {
|
|
|
|
if (numberOfMessages > 0) {
|
|
|
@ -237,6 +242,7 @@ typedef enum : NSUInteger {
|
|
|
|
- (void)viewDidAppear:(BOOL)animated{
|
|
|
|
- (void)viewDidAppear:(BOOL)animated{
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
[self startReadTimer];
|
|
|
|
[self startReadTimer];
|
|
|
|
|
|
|
|
_isVisible = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated{
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated{
|
|
|
@ -274,6 +280,10 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidDisappear:(BOOL)animated{
|
|
|
|
|
|
|
|
_isVisible = NO;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -449,9 +459,6 @@ typedef enum : NSUInteger {
|
|
|
|
return [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:contactId];
|
|
|
|
return [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:contactId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)callAction
|
|
|
|
-(void)callAction
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ([self isRedPhoneReachable]) {
|
|
|
|
if ([self isRedPhoneReachable]) {
|
|
|
@ -1251,24 +1258,44 @@ typedef enum : NSUInteger {
|
|
|
|
[self initializeToolbars];
|
|
|
|
[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 *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 *messageRowChanges = nil;
|
|
|
|
|
|
|
|
NSArray *sectionChanges = nil;
|
|
|
|
[[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] getSectionChanges:nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] getSectionChanges:§ionChanges
|
|
|
|
rowChanges:&messageRowChanges
|
|
|
|
rowChanges:&messageRowChanges
|
|
|
|
forNotifications:notifications
|
|
|
|
forNotifications:notifications
|
|
|
|
withMappings:self.messageMappings];
|
|
|
|
withMappings:self.messageMappings];
|
|
|
|
|
|
|
|
|
|
|
|
__block BOOL scrollToBottom = NO;
|
|
|
|
__block BOOL scrollToBottom = NO;
|
|
|
|
|
|
|
|
|
|
|
|
if (!messageRowChanges) {
|
|
|
|
if ([sectionChanges count] == 0 & [messageRowChanges count] == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[self.collectionView performBatchUpdates:^{
|
|
|
|
[self.collectionView performBatchUpdates:^{
|
|
|
|
|
|
|
|
|
|
|
|
for (YapDatabaseViewRowChange *rowChange in messageRowChanges)
|
|
|
|
for (YapDatabaseViewRowChange *rowChange in messageRowChanges)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (rowChange.type)
|
|
|
|
switch (rowChange.type)
|
|
|
|