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

Loading…
Cancel
Save