Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cancelUpload not working #116

Merged
merged 1 commit into from
Jan 3, 2019
Merged

fix cancelUpload not working #116

merged 1 commit into from
Jan 3, 2019

Conversation

BaderSerhan
Copy link
Contributor

Cancelling an upload is never working, due to the obj-C if condition which was comparing references, instead of strings.

Copy link
Contributor

@TSMMark TSMMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -226,7 +226,8 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
RCT_EXPORT_METHOD(cancelUpload: (NSString *)cancelUploadId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
[_urlSession getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
for (NSURLSessionTask *uploadTask in uploadTasks) {
if (uploadTask.taskDescription == cancelUploadId) {
if ([uploadTask.taskDescription isEqualToString:cancelUploadId]){
// == checks if references are equal, while isEqualToString checks the string value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this == comparison also an issue?

[data setObject:error.localizedDescription forKey:@"error"];
if (error.code == NSURLErrorCancelled) {
[self _sendEventWithName:@"RNFileUploader-cancelled" body:data];
} else {
[self _sendEventWithName:@"RNFileUploader-error" body:data];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like an issue to me, it is entering the if condition correctly.

@StevePotter StevePotter merged commit f098d0c into Vydia:master Jan 3, 2019
@BaderSerhan
Copy link
Contributor Author

When will this be published to npm? Every time I npm install or yarn install, I get the not working cancel function. How can I get the fixed version of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants