Attachment type in notification and description.

pull/1/head
Frederic Jacobs 9 years ago
parent ef6e658c38
commit a29eb5470f

@ -8,6 +8,7 @@
//
#import "TSAttachment.h"
#import "MIMETypeUtil.h"
@implementation TSAttachment
@ -34,4 +35,18 @@
return [f numberFromString:self.uniqueId];
}
- (NSString*)description {
NSString *attachmentString = NSLocalizedString(@"ATTACHMENT", nil);
if ([MIMETypeUtil isImage:self.contentType]) {
return [NSString stringWithFormat:@"📷 %@", attachmentString];
} else if ([MIMETypeUtil isVideo:self.contentType]) {
return [NSString stringWithFormat:@"📽 %@", attachmentString];
} else if ([MIMETypeUtil isAudio:self.contentType]) {
return [NSString stringWithFormat:@"📻 %@", attachmentString];
}
return attachmentString;
}
@end

@ -61,7 +61,9 @@ NSString * const TSAttachementsRelationshipEdgeName = @"TSAttachmentEdge";
- (NSString *)description{
if(self.attachments > 0){
return NSLocalizedString(@"ATTACHMENT", nil);
NSString *attachmentId = self.attachments[0];
TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId];
return attachment.description;
} else {
return self.body;
}

Loading…
Cancel
Save