Skip to content

Commit b022a38

Browse files
committed
evalJavaScript directly
1 parent 937a32e commit b022a38

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

dsbridge/DWKWebView.m

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,26 @@ -(NSString *)call:(NSString*) method :(NSString*) argStr
294294
del=[@"delete window." stringByAppendingString:cb];
295295
}
296296
NSString*js=[NSString stringWithFormat:@"try {%@(JSON.parse(decodeURIComponent(\"%@\")).data);%@; } catch(e){};",cb,(value == nil) ? @"" : value,del];
297-
__strong typeof(self) strongSelf = weakSelf;
298-
@synchronized(self)
299-
{
300-
UInt64 t=[[NSDate date] timeIntervalSince1970]*1000;
301-
jsCache=[jsCache stringByAppendingString:js];
302-
if(t-lastCallTime<50){
303-
if(!isPending){
304-
[strongSelf evalJavascript:50];
305-
isPending=true;
297+
dispatch_async(dispatch_get_main_queue(), ^{
298+
//__strong typeof(self) strongSelf = weakSelf;
299+
if (weakSelf != nil) {
300+
NSLog(@"evaluateJavaScript%@",js);
301+
@synchronized(weakSelf)
302+
{
303+
// UInt64 t=[[NSDate date] timeIntervalSince1970]*1000;
304+
// jsCache=[jsCache stringByAppendingString:js];
305+
// if(t-lastCallTime<50){
306+
// if(!isPending){
307+
// [strongSelf evalJavascript:50];
308+
// isPending=true;
309+
// }
310+
// }else{
311+
// [strongSelf evalJavascript:0];
312+
// }
313+
[weakSelf evaluateJavaScript:js completionHandler:nil];
306314
}
307-
}else{
308-
[strongSelf evalJavascript:0];
309315
}
310-
}
316+
});
311317

312318
};
313319

0 commit comments

Comments
 (0)