Skip to content

Commit 29e4bb2

Browse files
committed
evalJavaScript directly
1 parent 937a32e commit 29e4bb2

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

dsbridge/DWKWebView.m

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,25 @@ -(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+
@synchronized(weakSelf)
301+
{
302+
// UInt64 t=[[NSDate date] timeIntervalSince1970]*1000;
303+
// jsCache=[jsCache stringByAppendingString:js];
304+
// if(t-lastCallTime<50){
305+
// if(!isPending){
306+
// [strongSelf evalJavascript:50];
307+
// isPending=true;
308+
// }
309+
// }else{
310+
// [strongSelf evalJavascript:0];
311+
// }
312+
[weakSelf evaluateJavaScript:js completionHandler:nil];
306313
}
307-
}else{
308-
[strongSelf evalJavascript:0];
309314
}
310-
}
315+
});
311316

312317
};
313318

0 commit comments

Comments
 (0)