mirror of
https://github.com/danog/Telegram.git
synced 2024-12-02 09:27:55 +01:00
40 lines
905 B
Mathematica
40 lines
905 B
Mathematica
|
#import "TGMemoryImageCache+Signals.h"
|
||
|
|
||
|
@implementation TGMemoryImageCacheEvent
|
||
|
|
||
|
- (instancetype)initWithImage:(UIImage *)image attributes:(NSDictionary *)attributes
|
||
|
{
|
||
|
self = [super init];
|
||
|
if (self != nil)
|
||
|
{
|
||
|
_image = image;
|
||
|
_attributes = attributes;
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation TGMemoryImageCache (Signals)
|
||
|
|
||
|
- (SSignal *)signalForKey:(NSString *)key
|
||
|
{
|
||
|
NSDictionary *attributes = nil;
|
||
|
UIImage *image = [self imageForKey:key attributes:&attributes];
|
||
|
if (image != nil)
|
||
|
return [SSignal single:[[TGMemoryImageCacheEvent alloc] initWithImage:image attributes:attributes]];
|
||
|
else
|
||
|
return [SSignal fail:nil];
|
||
|
}
|
||
|
|
||
|
- (SSignal *)imageSignalForKey:(NSString *)key
|
||
|
{
|
||
|
UIImage *image = [self imageForKey:key attributes:NULL];
|
||
|
if (image != nil)
|
||
|
return [SSignal single:image];
|
||
|
else
|
||
|
return [SSignal fail:nil];
|
||
|
}
|
||
|
|
||
|
@end
|