connectNode method
Implementation
Future<NetworkParams?> connectNode(List<NetworkParams> nodes) async {
final isAvatarSupport = (await evalJavascript(
'settings.connectAll ? {}:null',
wrapPromise: false)) !=
null;
final dynamic res = await (isAvatarSupport
? evalJavascript(
'settings.connectAll(${jsonEncode(nodes.map((e) => e.endpoint).toList())})')
: evalJavascript(
'settings.connect(${jsonEncode(nodes.map((e) => e.endpoint).toList())})'));
if (res != null) {
final index = nodes.indexWhere((e) => e.endpoint!.trim() == res.trim());
if (_webViewOOMReload) {
print(
"webView OOM Reload evaluateJavascript====\n${_msgJavascript.keys.toString()}");
_msgJavascript.forEach((key, value) {
_web!.webViewController.evaluateJavascript(source: value);
});
_msgJavascript = {};
_webViewOOMReload = false;
}
return nodes[index > -1 ? index : 0];
}
return null;
}