From 223bcd74ad7a474e63d89a0cc882dd4a747caafe Mon Sep 17 00:00:00 2001 From: "wenzhao.yin" Date: Thu, 4 Aug 2016 07:07:27 -0700 Subject: [PATCH] Cancel check update task Summary: When call `[RCTDevMenu invalidate]`, it will cancel updateTask. But in fact, after the `[updateTask cancel]`, the updateTask's completionHandler will call `checkForUpdates` again, so it will create a new updateTask. Closes https://github.com/facebook/react-native/pull/6165 Differential Revision: D3669576 Pulled By: javache fbshipit-source-id: 443924b7f4be1716797fc5690e90d962cf31b923 --- React/Modules/RCTDevMenu.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/React/Modules/RCTDevMenu.m b/React/Modules/RCTDevMenu.m index 830bcc6c29e..1605c4057c7 100644 --- a/React/Modules/RCTDevMenu.m +++ b/React/Modules/RCTDevMenu.m @@ -659,8 +659,6 @@ RCT_EXPORT_METHOD(reload) } if (_updateTask) { - [_updateTask cancel]; - _updateTask = nil; return; } @@ -675,8 +673,10 @@ RCT_EXPORT_METHOD(reload) if (!error && HTTPResponse.statusCode == 205) { [strongSelf reload]; } else { - strongSelf->_updateTask = nil; - [strongSelf checkForUpdates]; + if (error.code != NSURLErrorCancelled) { + strongSelf->_updateTask = nil; + [strongSelf checkForUpdates]; + } } } });