mattermost-mobile/ios/Mattermost/OnPasteEventManager.m
Elias Nahum ee2a25df84
Fix iOS crash when pasting large images and included other file types (#3424)
* Fix iOS crash when pasting large images and included other file types

* Rename pasteImages to pasteFiles and fix copying heic images

* remove comment

* Feedback review
2019-10-24 20:41:38 +03:00

47 lines
1.1 KiB
Objective-C

//
// PasteEventManager.m
// Mattermost
//
// Created by Tek Min Ewe on 05/08/2019.
// Copyright © 2019 Facebook. All rights reserved.
//
#import "OnPasteEventManager.h"
@implementation OnPasteEventManager {
bool hasListeners;
}
RCT_EXPORT_MODULE();
-(void)startObserving {
hasListeners = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPaste:) name:@"onPaste" object:nil];
}
-(void)stopObserving {
hasListeners = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(NSArray<NSString *>*)supportedEvents {
return @[@"onPaste"];
}
-(void)onPaste:(NSNotification *)data {
if (!hasListeners) {
return;
}
[self sendEventWithName:@"onPaste" body:data.userInfo[@"data"]];
}
+(void)pasteFiles:(NSArray<NSDictionary *> *)data {
[[NSNotificationCenter defaultCenter] postNotificationName:@"onPaste" object:data userInfo:@{
@"data": data
}];
}
@end