From 52b82af52c72bf37d160383c9bc178d01412f312 Mon Sep 17 00:00:00 2001 From: Junyuan Feng Date: Tue, 3 May 2022 20:26:00 +0800 Subject: [PATCH] Fix & Optimize - fix ping when results is empty - optimize ping speed --- ios/Runner.xcodeproj/project.pbxproj | 12 ++++++------ lib/data/res/build_data.dart | 9 +++++---- lib/view/page/ping.dart | 19 ++++++++++++------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index ee83b286..0ea40b81 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -354,7 +354,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -362,7 +362,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.118; + MARKETING_VERSION = 1.0.119; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -484,7 +484,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -492,7 +492,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.118; + MARKETING_VERSION = 1.0.119; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -508,7 +508,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -516,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.118; + MARKETING_VERSION = 1.0.119; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index 4a9e2d6d..1dc03d6d 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,9 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 118; - static const String engine = "Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision c860cba910 (6 weeks ago) • 2022-03-25 00:23:12 -0500\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n"; - static const String buildAt = "2022-05-03 12:05:15.250795"; - static const int modifications = 4; + static const int build = 119; + static const String engine = + "Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision c860cba910 (6 weeks ago) • 2022-03-25 00:23:12 -0500\nEngine • revision 57d3bac3dd\nTools • Dart 2.16.2 • DevTools 2.9.2\n"; + static const String buildAt = "2022-05-03 12:06:26.688732"; + static const int modifications = 0; } diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index 7ae58bbc..17b46fbb 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -77,6 +77,9 @@ class _PingPageState extends State String _buildPingSummary(PingResult result) { final ip = result.ip ?? 'unkown'; + if (result.results == null || result.results!.isEmpty) { + return '$ip - no results'; + } final ttl = result.results?.first.ttl ?? 'unkown'; final loss = result.statistic?.loss ?? 'unkown'; final min = result.statistic?.min ?? 'unkown'; @@ -91,14 +94,15 @@ class _PingPageState extends State showSnackBar(context, const Text('Please input a target')); return; } - for (var si in locator().servers) { - if (si.client == null) { - continue; + + await Future.wait(locator().servers.map((e) async { + if (e.client == null) { + return; } - final result = await si.client!.run('ping -c 3 $target').string; - _results.add(PingResult.parse(si.info.name, result)); + final result = await e.client!.run('ping -c 3 $target').string; + _results.add(PingResult.parse(e.info.name, result)); setState(() {}); - } + })); } Widget _buildControl() { @@ -115,7 +119,7 @@ class _PingPageState extends State foregroundColor: MaterialStateProperty.all(primaryColor)), child: Row( children: const [ - Icon(Icons.stop), + Icon(Icons.delete), SizedBox( width: 7, ), @@ -124,6 +128,7 @@ class _PingPageState extends State ), onPressed: () { _results.clear(); + setState(() {}); }, ), TextButton(