pull/1/head
Aaron Raimist 10 years ago committed by Frederic Jacobs
parent 9c611fad79
commit 0d97edf7af

@ -208,8 +208,7 @@ typedef enum : NSUInteger {
self.inputToolbar.contentView.rightBarButtonItem = _messageButton; self.inputToolbar.contentView.rightBarButtonItem = _messageButton;
} }
-(void)viewWillAppear:(BOOL)animated -(void)viewWillAppear:(BOOL)animated {
{
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self initializeToolbars]; [self initializeToolbars];
@ -765,20 +764,13 @@ typedef enum : NSUInteger {
- (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView - (CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
{ {
TSMessageAdapter * msg = [self messageAtIndexPath:indexPath]; if ([self shouldShowMessageStatusAtIndexPath:indexPath]) {
if([self.thread isKindOfClass:[TSGroupThread class]]) {
if(msg.messageType == TSIncomingMessageAdapter) {
return 16.0f;
}
}
else if (msg.messageType == TSOutgoingMessageAdapter) {
return 16.0f; return 16.0f;
} }
return 0.0f; return 0.0f;
} }
#pragma mark - Actions #pragma mark - Actions
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapMessageBubbleAtIndexPath:(NSIndexPath *)indexPath - (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapMessageBubbleAtIndexPath:(NSIndexPath *)indexPath
@ -1117,8 +1109,7 @@ typedef enum : NSUInteger {
* Presenting UIImagePickerController * Presenting UIImagePickerController
*/ */
- (void)takePictureOrVideo - (void)takePictureOrVideo {
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self; picker.delegate = self;
picker.allowsEditing = NO; picker.allowsEditing = NO;
@ -1164,8 +1155,7 @@ typedef enum : NSUInteger {
/* /*
* Fetching data from UIImagePickerController * Fetching data from UIImagePickerController
*/ */
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
{
[UIUtil modalCompletionBlock](); [UIUtil modalCompletionBlock]();
[self resetFrame]; [self resetFrame];
@ -1217,13 +1207,11 @@ typedef enum : NSUInteger {
}]; }];
} }
-(NSData*)qualityAdjustedAttachmentForImage:(UIImage*)image - (NSData*)qualityAdjustedAttachmentForImage:(UIImage*)image {
{
return UIImageJPEGRepresentation([self adjustedImageSizedForSending:image], [self compressionRate]); return UIImageJPEGRepresentation([self adjustedImageSizedForSending:image], [self compressionRate]);
} }
-(UIImage*)adjustedImageSizedForSending:(UIImage*)image - (UIImage*)adjustedImageSizedForSending:(UIImage*)image {
{
CGFloat correctedWidth; CGFloat correctedWidth;
switch ([Environment.preferences imageUploadQuality]) { switch ([Environment.preferences imageUploadQuality]) {
case TSImageQualityUncropped: case TSImageQualityUncropped:
@ -1245,8 +1233,7 @@ typedef enum : NSUInteger {
return [self imageScaled:image toMaxSize:correctedWidth]; return [self imageScaled:image toMaxSize:correctedWidth];
} }
- (UIImage*)imageScaled:(UIImage *)image toMaxSize:(CGFloat)size - (UIImage*)imageScaled:(UIImage *)image toMaxSize:(CGFloat)size {
{
CGFloat scaleFactor; CGFloat scaleFactor;
CGFloat aspectRatio = image.size.height / image.size.width; CGFloat aspectRatio = image.size.height / image.size.width;
@ -1267,8 +1254,7 @@ typedef enum : NSUInteger {
return updatedImage; return updatedImage;
} }
-(CGFloat)compressionRate - (CGFloat)compressionRate {
{
switch ([Environment.preferences imageUploadQuality]) { switch ([Environment.preferences imageUploadQuality]) {
case TSImageQualityUncropped: case TSImageQualityUncropped:
return 1; return 1;
@ -1306,8 +1292,7 @@ typedef enum : NSUInteger {
} }
- (void)yapDatabaseModified:(NSNotification *)notification - (void)yapDatabaseModified:(NSNotification *)notification {
{
if(isGroupConversation) { if(isGroupConversation) {
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
TSGroupThread* gThread = (TSGroupThread*)self.thread; TSGroupThread* gThread = (TSGroupThread*)self.thread;
@ -1317,16 +1302,14 @@ typedef enum : NSUInteger {
NSArray *notifications = [self.uiDatabaseConnection beginLongLivedReadTransaction]; NSArray *notifications = [self.uiDatabaseConnection beginLongLivedReadTransaction];
if ( ![[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] hasChangesForNotifications:notifications]) if ( ![[self.uiDatabaseConnection ext:TSMessageDatabaseViewExtensionName] hasChangesForNotifications:notifications]) {
{
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){ [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){
[self.messageMappings updateWithTransaction:transaction]; [self.messageMappings updateWithTransaction:transaction];
}]; }];
return; return;
} }
if (!_isVisible) if (!_isVisible) {
{
// Since we moved our databaseConnection to a new commit, // Since we moved our databaseConnection to a new commit,
// we need to update the mappings too. // we need to update the mappings too.
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){ [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction){
@ -1346,16 +1329,13 @@ typedef enum : NSUInteger {
__block BOOL scrollToBottom = NO; __block BOOL scrollToBottom = NO;
if ([sectionChanges count] == 0 & [messageRowChanges count] == 0) 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)
{
case YapDatabaseViewChangeDelete : case YapDatabaseViewChangeDelete :
{ {
[self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]]; [self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]];
@ -1406,8 +1386,8 @@ typedef enum : NSUInteger {
} }
#pragma mark - UICollectionView DataSource #pragma mark - UICollectionView DataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
NSInteger numberOfMessages = (NSInteger)[self.messageMappings numberOfItemsInSection:(NSUInteger)section]; NSInteger numberOfMessages = (NSInteger)[self.messageMappings numberOfItemsInSection:(NSUInteger)section];
return numberOfMessages; return numberOfMessages;
} }
@ -1496,8 +1476,7 @@ typedef enum : NSUInteger {
#pragma mark Accessory View #pragma mark Accessory View
-(void)didPressAccessoryButton:(UIButton *)sender - (void)didPressAccessoryButton:(UIButton *)sender {
{
[self dismissKeyBoard]; [self dismissKeyBoard];
UIView *presenter = self.parentViewController.view; UIView *presenter = self.parentViewController.view;
@ -1545,8 +1524,7 @@ typedef enum : NSUInteger {
return [super collectionView:collectionView canPerformAction:action forItemAtIndexPath:indexPath withSender:sender]; return [super collectionView:collectionView canPerformAction:action forItemAtIndexPath:indexPath withSender:sender];
} }
- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender - (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
{
if (action == @selector(delete:)) { if (action == @selector(delete:)) {
[self deleteMessageAtIndexPath:indexPath]; [self deleteMessageAtIndexPath:indexPath];
} }
@ -1617,8 +1595,7 @@ typedef enum : NSUInteger {
#pragma mark Drafts #pragma mark Drafts
- (void)loadDraftInCompose - (void)loadDraftInCompose {
{
__block NSString *placeholder; __block NSString *placeholder;
[self.editingDatabaseConnection asyncReadWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.editingDatabaseConnection asyncReadWithBlock:^(YapDatabaseReadTransaction *transaction) {
placeholder = [_thread currentDraftWithTransaction:transaction]; placeholder = [_thread currentDraftWithTransaction:transaction];
@ -1630,8 +1607,7 @@ typedef enum : NSUInteger {
}]; }];
} }
- (void)saveDraft - (void)saveDraft {
{
if (self.inputToolbar.hidden == NO) { if (self.inputToolbar.hidden == NO) {
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[_thread setDraft:self.inputToolbar.contentView.textView.text transaction:transaction]; [_thread setDraft:self.inputToolbar.contentView.textView.text transaction:transaction];

Loading…
Cancel
Save