mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 01:52:44 +02:00
Remove flairs and related groups.
This commit is contained in:
@@ -497,16 +497,7 @@ static BOOL _disableLongPressGestureOnEvent;
|
||||
// Display sender's name except if the name appears in the displayed text (see emote and membership events)
|
||||
if (bubbleData.shouldHideSenderName == NO)
|
||||
{
|
||||
if (bubbleData.senderFlair)
|
||||
{
|
||||
[self renderSenderFlair];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.userNameLabel.text = bubbleData.senderDisplayName;
|
||||
}
|
||||
|
||||
|
||||
self.userNameLabel.text = bubbleData.senderDisplayName;
|
||||
self.userNameLabel.hidden = NO;
|
||||
self.userNameTapGestureMaskView.userInteractionEnabled = YES;
|
||||
}
|
||||
@@ -800,75 +791,6 @@ static BOOL _disableLongPressGestureOnEvent;
|
||||
mxkCellData = cellData;
|
||||
}
|
||||
|
||||
- (void)renderSenderFlair
|
||||
{
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ ", bubbleData.senderDisplayName]];
|
||||
|
||||
NSUInteger index = 0;
|
||||
|
||||
for (MXGroup *group in bubbleData.senderFlair)
|
||||
{
|
||||
NSString *mxcAvatarURI = group.profile.avatarUrl;
|
||||
NSString *cacheFilePath = [MXMediaManager thumbnailCachePathForMatrixContentURI:mxcAvatarURI andType:@"image/jpeg" inFolder:kMXMediaManagerDefaultCacheFolder toFitViewSize:CGSizeMake(12, 12) withMethod:MXThumbnailingMethodCrop];
|
||||
|
||||
// Check whether the avatar url is valid
|
||||
if (cacheFilePath)
|
||||
{
|
||||
UIImage *image = [MXMediaManager loadThroughCacheWithFilePath:cacheFilePath];
|
||||
if (image)
|
||||
{
|
||||
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
|
||||
textAttachment.image = [MXKTools resizeImageWithRoundedCorners:image toSize:CGSizeMake(12, 12)];
|
||||
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
|
||||
[attributedString appendAttributedString:attrStringWithImage];
|
||||
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *downloadId = [MXMediaManager thumbnailDownloadIdForMatrixContentURI:mxcAvatarURI
|
||||
inFolder:kMXMediaManagerDefaultCacheFolder
|
||||
toFitViewSize:CGSizeMake(12, 12)
|
||||
withMethod:MXThumbnailingMethodCrop];
|
||||
// Check whether the download is in progress.
|
||||
MXMediaLoader* loader = [MXMediaManager existingDownloaderWithIdentifier:downloadId];
|
||||
if (loader)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXMediaLoaderStateDidChangeNotification object:loader];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFlairDownloadStateChange:) name:kMXMediaLoaderStateDidChangeNotification object:loader];
|
||||
}
|
||||
else
|
||||
{
|
||||
MXWeakify(self);
|
||||
[bubbleData.mxSession.mediaManager downloadThumbnailFromMatrixContentURI:mxcAvatarURI
|
||||
withType:@"image/jpeg"
|
||||
inFolder:kMXMediaManagerDefaultCacheFolder
|
||||
toFitViewSize:CGSizeMake(12, 12)
|
||||
withMethod:MXThumbnailingMethodCrop
|
||||
success:^(NSString *outputFilePath) {
|
||||
// Refresh sender flair
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self renderSenderFlair];
|
||||
}
|
||||
failure:nil];
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
if (index == 3)
|
||||
{
|
||||
if (bubbleData.senderFlair.count > 3)
|
||||
{
|
||||
NSAttributedString *more = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"+%tu", (bubbleData.senderFlair.count - 3)] attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:11.0], NSBaselineOffsetAttributeName:@(+2)}];
|
||||
[attributedString appendAttributedString:more];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.userNameLabel.attributedText = attributedString;
|
||||
}
|
||||
|
||||
- (void)renderGif
|
||||
{
|
||||
if (self.attachmentView && bubbleData.attachment)
|
||||
@@ -1292,23 +1214,6 @@ static BOOL _disableLongPressGestureOnEvent;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onFlairDownloadStateChange:(NSNotification *)notif
|
||||
{
|
||||
MXMediaLoader *loader = (MXMediaLoader*)notif.object;
|
||||
switch (loader.state) {
|
||||
case MXMediaLoaderStateDownloadCompleted:
|
||||
[self renderSenderFlair];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXMediaLoaderStateDidChangeNotification object:loader];
|
||||
break;
|
||||
case MXMediaLoaderStateDownloadFailed:
|
||||
case MXMediaLoaderStateCancelled:
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXMediaLoaderStateDidChangeNotification object:loader];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startProgressUI
|
||||
{
|
||||
self.progressView.hidden = YES;
|
||||
|
||||
Reference in New Issue
Block a user