Merge branch 'mkirk/prod-crashes'

pull/1/head
Michael Kirk 8 years ago
commit 7f5975f02c

@ -25,6 +25,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
// MARK: Views // MARK: Views
var isViewLoaded = false
var hasConstraints = false var hasConstraints = false
var blurView: UIVisualEffectView! var blurView: UIVisualEffectView!
var dateFormatter: DateFormatter? var dateFormatter: DateFormatter?
@ -158,7 +159,9 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
} }
func didBecomeActive() { func didBecomeActive() {
shouldRemoteVideoControlsBeHidden = false if (self.isViewLoaded) {
shouldRemoteVideoControlsBeHidden = false
}
} }
// MARK: View Lifecycle // MARK: View Lifecycle
@ -195,6 +198,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
call.addObserverAndSyncState(observer: self) call.addObserverAndSyncState(observer: self)
Environment.getCurrent().callService.addObserverAndSyncState(observer: self) Environment.getCurrent().callService.addObserverAndSyncState(observer: self)
self.isViewLoaded = true
} }
// MARK: - Create Views // MARK: - Create Views

@ -487,8 +487,17 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
_callOnOpen = callOnViewAppearing; _callOnOpen = callOnViewAppearing;
[self.uiDatabaseConnection beginLongLivedReadTransaction]; [self.uiDatabaseConnection beginLongLivedReadTransaction];
self.messageMappings =
[[YapDatabaseViewMappings alloc] initWithGroups:@[ thread.uniqueId ] view:TSMessageDatabaseViewExtensionName]; if (thread.uniqueId.length > 0) {
self.messageMappings = [[YapDatabaseViewMappings alloc] initWithGroups:@[ thread.uniqueId ]
view:TSMessageDatabaseViewExtensionName];
} else {
OWSFail(@"uniqueId unexpectedly empty for thread: %@", thread);
self.messageMappings =
[[YapDatabaseViewMappings alloc] initWithGroups:@[] view:TSMessageDatabaseViewExtensionName];
return;
}
// We need to impose the range restrictions on the mappings immediately to avoid // We need to impose the range restrictions on the mappings immediately to avoid
// doing a great deal of unnecessary work and causing a perf hotspot. // doing a great deal of unnecessary work and causing a perf hotspot.
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
@ -2202,33 +2211,38 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
if ([[messageItem media] isKindOfClass:[TSPhotoAdapter class]]) { if ([[messageItem media] isKindOfClass:[TSPhotoAdapter class]]) {
TSPhotoAdapter *messageMedia = (TSPhotoAdapter *)[messageItem media]; TSPhotoAdapter *messageMedia = (TSPhotoAdapter *)[messageItem media];
UIImage *tappedImage = ((UIImageView *)[messageMedia mediaView]).image; UIView *mediaView = [messageMedia mediaView];
if (![mediaView isKindOfClass:[UIImageView class]]) {
OWSFail(@"unexpected mediaView of type: %@", [mediaView class]);
return;
}
UIImageView *imageView = (UIImageView *)mediaView;
UIImage *tappedImage = imageView.image;
if (tappedImage == nil) { if (tappedImage == nil) {
DDLogWarn(@"tapped TSPhotoAdapter with nil image"); DDLogWarn(@"tapped TSPhotoAdapter with nil image");
} else { return;
UIWindow *window = [UIApplication sharedApplication].keyWindow; }
JSQMessagesCollectionViewCell *cell UIWindow *window = [UIApplication sharedApplication].keyWindow;
= (JSQMessagesCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; JSQMessagesCollectionViewCell *cell
OWSAssert([cell isKindOfClass:[JSQMessagesCollectionViewCell class]]); = (JSQMessagesCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
CGRect convertedRect = [cell.mediaView convertRect:cell.mediaView.bounds toView:window]; OWSAssert([cell isKindOfClass:[JSQMessagesCollectionViewCell class]]);
CGRect convertedRect = [cell.mediaView convertRect:cell.mediaView.bounds toView:window];
__block TSAttachment *attachment = nil; __block TSAttachment *attachment = nil;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
attachment = [TSAttachment fetchObjectWithUniqueID:messageMedia.attachmentId attachment =
transaction:transaction]; [TSAttachment fetchObjectWithUniqueID:messageMedia.attachmentId transaction:transaction];
}]; }];
if ([attachment isKindOfClass:[TSAttachmentStream class]]) { if ([attachment isKindOfClass:[TSAttachmentStream class]]) {
TSAttachmentStream *attStream = (TSAttachmentStream *)attachment; TSAttachmentStream *attStream = (TSAttachmentStream *)attachment;
FullImageViewController *vc = FullImageViewController *vc = [[FullImageViewController alloc] initWithAttachment:attStream
[[FullImageViewController alloc] initWithAttachment:attStream fromRect:convertedRect
fromRect:convertedRect forInteraction:interaction
forInteraction:interaction messageItem:messageItem
messageItem:messageItem isAnimated:NO];
isAnimated:NO];
[vc presentFromViewController:self]; [vc presentFromViewController:self];
}
} }
} else if ([[messageItem media] isKindOfClass:[TSAnimatedAdapter class]]) { } else if ([[messageItem media] isKindOfClass:[TSAnimatedAdapter class]]) {
// Show animated image full-screen // Show animated image full-screen
@ -3956,20 +3970,30 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
TSThread *thread = self.thread; TSThread *thread = self.thread;
uint64_t lastVisibleTimestamp = self.lastVisibleTimestamp; uint64_t lastVisibleTimestamp = self.lastVisibleTimestamp;
[self.editingDatabaseConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [self.editingDatabaseConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
NSMutableArray<id<OWSReadTracking>> *interactions = [NSMutableArray new]; NSMutableArray<id<OWSReadTracking>> *interactions = [NSMutableArray new];
[[TSDatabaseView unseenDatabaseViewExtension:transaction] [[TSDatabaseView unseenDatabaseViewExtension:transaction]
enumerateRowsInGroup:thread.uniqueId enumerateRowsInGroup:thread.uniqueId
usingBlock:^( usingBlock:^(
NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) { NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) {
TSInteraction *interaction = object; if (![object conformsToProtocol:@protocol(OWSReadTracking)]) {
if (interaction.timestampForSorting > lastVisibleTimestamp) { OWSFail(@"Expected to conform to OWSReadTracking: object with class: %@ collection: %@ "
@"key: %@",
[object class],
collection,
key);
return;
}
id<OWSReadTracking> possiblyRead = (id<OWSReadTracking>)object;
if (possiblyRead.timestampForSorting > lastVisibleTimestamp) {
*stop = YES; *stop = YES;
return; return;
} }
id<OWSReadTracking> possiblyRead = (id<OWSReadTracking>)object;
OWSAssert(!possiblyRead.read); OWSAssert(!possiblyRead.read);
if (!possiblyRead.read) { if (!possiblyRead.read) {
[interactions addObject:possiblyRead]; [interactions addObject:possiblyRead];

@ -726,6 +726,11 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
keyboardOnViewAppearing:(BOOL)keyboardOnViewAppearing keyboardOnViewAppearing:(BOOL)keyboardOnViewAppearing
callOnViewAppearing:(BOOL)callOnViewAppearing callOnViewAppearing:(BOOL)callOnViewAppearing
{ {
if (thread == nil) {
OWSFail(@"Thread unexpectedly nil");
return;
}
// We do this synchronously if we're already on the main thread. // We do this synchronously if we're already on the main thread.
DispatchMainThreadSafe(^{ DispatchMainThreadSafe(^{
MessagesViewController *mvc = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController" MessagesViewController *mvc = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController"

@ -221,7 +221,8 @@ NS_ASSUME_NONNULL_BEGIN
NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) { NSString *collection, NSString *key, id object, id metadata, NSUInteger index, BOOL *stop) {
if (![object conformsToProtocol:@protocol(OWSReadTracking)]) { if (![object conformsToProtocol:@protocol(OWSReadTracking)]) {
DDLogError(@"%@ Unexpected object in unread messages: %@", self.tag, object); OWSFail(@"%@ Unexpected object in unread messages: %@", self.tag, object);
return;
} }
[messages addObject:(id<OWSReadTracking>)object]; [messages addObject:(id<OWSReadTracking>)object];
}]; }];

@ -15,6 +15,7 @@
*/ */
@property (nonatomic, readonly, getter=wasRead) BOOL read; @property (nonatomic, readonly, getter=wasRead) BOOL read;
@property (nonatomic, readonly) uint64_t timestampForSorting;
@property (nonatomic, readonly) NSString *uniqueThreadId; @property (nonatomic, readonly) NSString *uniqueThreadId;
- (BOOL)shouldAffectUnreadCounts; - (BOOL)shouldAffectUnreadCounts;

Loading…
Cancel
Save