no message

This commit is contained in:
Ilya Laktyushin 2018-08-24 07:28:53 +03:00
parent c013a50d31
commit 8028166b15
2 changed files with 18 additions and 6 deletions

View File

@ -101,7 +101,10 @@
break; break;
case TGMediaOriginTypeWebpage: case TGMediaOriginTypeWebpage:
info->_webpageUrl = keyComponents[1]; {
NSString *url = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (CFStringRef)keyComponents[1], CFSTR(""), kCFStringEncodingUTF8);
info->_webpageUrl = url;
}
break; break;
case TGMediaOriginTypeWallpaper: case TGMediaOriginTypeWallpaper:
@ -111,11 +114,11 @@
default: default:
return nil; return nil;
} }
if ([components[1] length] > 0) if (components.count > 1 && [components[1] length] > 0)
info->_fileReference = [NSData dataWithHexString:components[1]]; info->_fileReference = [NSData dataWithHexString:components[1]];
NSMutableDictionary *fileReferences = [[NSMutableDictionary alloc] init]; NSMutableDictionary *fileReferences = [[NSMutableDictionary alloc] init];
if ([components[2] length] > 0) if (components.count > 2 && [components[2] length] > 0)
{ {
NSArray *refComponents = [components[2] componentsSeparatedByString:@","]; NSArray *refComponents = [components[2] componentsSeparatedByString:@","];
for (NSString *ref in refComponents) for (NSString *ref in refComponents)
@ -174,7 +177,10 @@
return [NSString stringWithFormat:@"%d|%@", _type, _chatPhotoPeerId]; return [NSString stringWithFormat:@"%d|%@", _type, _chatPhotoPeerId];
case TGMediaOriginTypeWebpage: case TGMediaOriginTypeWebpage:
return [NSString stringWithFormat:@"%d|%@", _type, _webpageUrl]; {
NSString *url = [TGStringUtils stringByEscapingForURL:_webpageUrl];
return [NSString stringWithFormat:@"%d|%@", _type, url];
}
case TGMediaOriginTypeWallpaper: case TGMediaOriginTypeWallpaper:
return [NSString stringWithFormat:@"%d|%@", _type, _wallpaperId]; return [NSString stringWithFormat:@"%d|%@", _type, _wallpaperId];

View File

@ -13,6 +13,7 @@ static TGCache *sharedCache = nil;
@interface TGRemoteImageView () @interface TGRemoteImageView ()
@property (atomic, strong) NSString *path; @property (atomic, strong) NSString *path;
@property (atomic, strong) NSString *currentCacheUrl;
@property (nonatomic, strong) UIImageView *placeholderView; @property (nonatomic, strong) UIImageView *placeholderView;
@ -231,8 +232,13 @@ static TGCache *sharedCache = nil;
TGCache *cache = _cache != nil ? _cache : [TGRemoteImageView sharedCache]; TGCache *cache = _cache != nil ? _cache : [TGRemoteImageView sharedCache];
NSString *cacheUrl = filter == nil ? url : [[NSString alloc] initWithFormat:@"{filter:%@}%@", filter, url]; NSString *trimmedUrl = url;
NSArray *components = [trimmedUrl componentsSeparatedByString:@"_"];
if (components.count >= 5)
trimmedUrl = [NSString stringWithFormat:@"%@_%@_%@_%@", components[0], components[1], components[2], components[3]];
NSString *cacheUrl = filter == nil ? trimmedUrl : [[NSString alloc] initWithFormat:@"{filter:%@}%@", filter, trimmedUrl];
self.currentCacheUrl = cacheUrl;
UIImage *image = [cache cachedImage:cacheUrl availability:TGCacheMemory]; UIImage *image = [cache cachedImage:cacheUrl availability:TGCacheMemory];
if (image == nil) if (image == nil)
@ -461,7 +467,7 @@ static TGCache *sharedCache = nil;
if (_useCache) if (_useCache)
{ {
TGCache *cache = _cache != nil ? _cache : [TGRemoteImageView sharedCache]; TGCache *cache = _cache != nil ? _cache : [TGRemoteImageView sharedCache];
[cache cacheImage:image withData:nil url:self.currentUrl availability:TGCacheMemory]; [cache cacheImage:image withData:nil url:self.currentCacheUrl availability:TGCacheMemory];
} }
#endif #endif