@@ -19,6 +19,9 @@ @implementation WebViewJavascriptBridge {
1919 WVJB_WEAK id _webViewDelegate;
2020 long _uniqueId;
2121 WebViewJavascriptBridgeBase *_base;
22+ #if defined WVJB_PLATFORM_IOS
23+ NSUInteger _numRequestsLoading;
24+ #endif
2225}
2326
2427/* API
@@ -183,9 +186,9 @@ - (void) _platformSpecificDealloc {
183186
184187- (void )webViewDidFinishLoad : (UIWebView *)webView {
185188 if (webView != _webView) { return ; }
186-
189+ _numRequestsLoading--;
187190
188- if ( ![[webView stringByEvaluatingJavaScriptFromString: [_base webViewJavascriptCheckCommand ]] isEqualToString: @" true" ]) {
191+ if ( _numRequestsLoading <= 0 && ![[webView stringByEvaluatingJavaScriptFromString: [_base webViewJavascriptCheckCommand ]] isEqualToString: @" true" ]) {
189192 [_base injectJavascriptFile: YES ];
190193 }
191194 [_base dispatchStartUpMessageQueue ];
@@ -200,7 +203,8 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView {
200203- (void )webView : (UIWebView *)webView didFailLoadWithError : (NSError *)error {
201204 if (webView != _webView) { return ; }
202205
203-
206+ _numRequestsLoading--;
207+ // watch error code 101
204208 __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
205209 if (strongDelegate && [strongDelegate respondsToSelector: @selector (webView:didFailLoadWithError: )]) {
206210 [strongDelegate webView: webView didFailLoadWithError: error];
@@ -228,7 +232,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
228232
229233- (void )webViewDidStartLoad : (UIWebView *)webView {
230234 if (webView != _webView) { return ; }
231-
235+ _numRequestsLoading++;
232236
233237 __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate;
234238 if (strongDelegate && [strongDelegate respondsToSelector: @selector (webViewDidStartLoad: )]) {
0 commit comments