From a1201920533e30873974eeedfc2cd2489766a4e5 Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Mon, 20 Apr 2020 11:59:35 -0400 Subject: [PATCH] conversations: fix constraints Change-Id: I74b51ec9a9e1188b9bbf36b1472dc9491304d99e --- src/MessagesVC.mm | 20 ++++++++------------ src/views/IMTableCellView.mm | 10 +++++++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/MessagesVC.mm b/src/MessagesVC.mm index 8a2232b8..01a9a000 100644 --- a/src/MessagesVC.mm +++ b/src/MessagesVC.mm @@ -83,7 +83,7 @@ CGFloat const MESSAGE_TEXT_PADDING = 10; CGFloat const MAX_TRANSFERED_IMAGE_SIZE = 250; CGFloat const BUBBLE_HEIGHT_FOR_TRANSFERED_FILE = 87; CGFloat const HEIGHT_FOR_COMPOSING_INDICATOR = 37; -CGFloat const HEIGHT_DEFAULT = 1; +CGFloat const HEIGHT_DEFAULT = 34; NSInteger const MEESAGE_MARGIN = 21; NSInteger const SEND_PANEL_DEFAULT_HEIGHT = 60; NSInteger const SEND_PANEL_MAX_HEIGHT = 120; @@ -191,6 +191,9 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { return; } auto itIndex = distance(conv->interactions.begin(),it); + if (itIndex >= ([conversationView numberOfRows] - 1)) { + return; + } NSRange rangeToUpdate = NSMakeRange(itIndex, 2); NSIndexSet* indexSet = [NSIndexSet indexSetWithIndexesInRange:rangeToUpdate]; //reload previous message to update bubbleview @@ -525,15 +528,13 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - auto* conv = [self getCurrentConversation]; - if (conv == nil) return nil; IMTableCellView* result; auto it = conv->interactions.begin(); - auto size = conv->interactions.size(); + auto size = [conversationView numberOfRows] - 1; if (row > size) { return [[NSView alloc] init]; } @@ -644,7 +645,6 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { [result updateMessageConstraint:messageSize.width andHeight:messageSize.height timeIsVisible:shouldDisplayTime isTopPadding: shouldApplyPadding]; [[result.msgView textStorage] appendAttributedString:msgAttString]; - // [result.msgView checkTextInDocument:nil]; NSDataDetector *linkDetector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil]; NSArray *matches = [linkDetector matchesInString:result.msgView.string options:0 range:NSMakeRange(0, result.msgView.string.length)]; @@ -687,17 +687,13 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { if (conv == nil) return HEIGHT_DEFAULT; - if (row > conv->interactions.size()) { - return HEIGHT_DEFAULT; - } - - auto size = conv->interactions.size(); - if (row == size) { + auto size = [conversationView numberOfRows] - 1; + if (row >= size) { //last item peer composing view if (peerComposingMessage) { return HEIGHT_FOR_COMPOSING_INDICATOR; } - return 0.1; + return 1; } auto it = conv->interactions.begin(); diff --git a/src/views/IMTableCellView.mm b/src/views/IMTableCellView.mm index 4283f74e..373f52eb 100644 --- a/src/views/IMTableCellView.mm +++ b/src/views/IMTableCellView.mm @@ -152,7 +152,7 @@ NSString* const TIME_BOX_HEIGHT = @"34"; } - (void) invalidateImageConstraints { -[NSLayoutConstraint deactivateConstraints:[self.transferedImage constraints]]; + [NSLayoutConstraint deactivateConstraints:[self.transferedImage constraints]]; } - (uint64_t)interaction @@ -207,4 +207,12 @@ NSString* const TIME_BOX_HEIGHT = @"34"; return NO; } +- (void)setFrameSize:(NSSize)newSize +{ + if (newSize.height == 1) { + return; + } + [super setFrameSize: newSize]; +} + @end -- GitLab