Skip to content

Commit

Permalink
Merge pull request #207 from osociety/fix-ui-slowness
Browse files Browse the repository at this point in the history
Fix for slowness of device scan
  • Loading branch information
git-elliot authored Nov 16, 2024
2 parents 4ab7fa3 + fa12b7b commit 413949e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-US/changelogs/29.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed slowness of devices scan.
2 changes: 1 addition & 1 deletion integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void main() {
await tester.tap(devicesButton);
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAny);
await tester.pumpAndSettle(const Duration(seconds: 4));
await tester.pumpAndSettle();
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAtLeast(2));

Expand Down
15 changes: 7 additions & 8 deletions lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:network_tools_flutter/network_tools_flutter.dart';
import 'package:vernet/helper/utils_helper.dart';
import 'package:vernet/injection.dart';
import 'package:vernet/main.dart';
import 'package:vernet/models/device_in_the_network.dart';
import 'package:vernet/models/isar/device.dart';
import 'package:vernet/models/isar/scan.dart';
import 'package:vernet/repository/notification_service.dart';
Expand Down Expand Up @@ -38,7 +37,7 @@ class HostScanBloc extends Bloc<HostScanEvent, HostScanState> {
String? subnet;

/// List of all ActiveHost devices that got found in the current scan
final List<DeviceInTheNetwork> deviceInTheNetworkList = [];
final Set<Device> devicesSet = {};

/// mDNS for each ip
final Map<String, MdnsInfo> mDnsDevices = {};
Expand All @@ -47,7 +46,7 @@ class HostScanBloc extends Bloc<HostScanEvent, HostScanState> {
Initialized event,
Emitter<HostScanState> emit,
) async {
deviceInTheNetworkList.clear();
devicesSet.clear();
mDnsDevices.clear();
emit(const HostScanState.loadInProgress());
await initializeWifiParameters(emit);
Expand Down Expand Up @@ -82,16 +81,16 @@ class HostScanBloc extends Bloc<HostScanEvent, HostScanState> {
) async {
emit(const HostScanState.loadInProgress());

final Set<Device> devices = {};
final deviceStream =
getIt<DeviceScannerService>().startNewScan(subnet!, ip!, gatewayIp!);
await for (final Device device in deviceStream) {
devices.add(device);
emit(HostScanState.foundNewDevice(devices));
devicesSet.add(device);
emit(const HostScanState.loadInProgress());
emit(HostScanState.foundNewDevice(devicesSet));
}

await NotificationService.showNotificationWithActions();
emit(HostScanState.loadSuccess(devices));
emit(HostScanState.loadSuccess(devicesSet));
}

Future<void> _loadScanAndShowResults(
Expand All @@ -100,10 +99,10 @@ class HostScanBloc extends Bloc<HostScanEvent, HostScanState> {
) async {
emit(const HostScanState.loadInProgress());

final Set<Device> devicesSet = {};
final deviceStream = await getIt<DeviceScannerService>().getOnGoingScan();
deviceStream.listen((devices) {
devicesSet.addAll(devices);
emit(const HostScanState.loadInProgress());
emit(HostScanState.foundNewDevice(devicesSet));
});

Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,10 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
sha256: "746e5369a43170c25816cc472ee016d3a66bc13fcf430c0bc41ad7b4b2922051"
sha256: "95f9997ca1fb9799d494d0cb2a780fd7be075818d59f00c43832ed112b158a82"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.3"
shared_preferences_android:
dependency: transitive
description:
Expand Down Expand Up @@ -1224,10 +1224,10 @@ packages:
dependency: transitive
description:
name: url_launcher_linux
sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
version: "3.2.1"
url_launcher_macos:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A Network Analyzer

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.9+28
version: 1.1.0+29

environment:
sdk: ">=2.17.0 <3.0.0"
Expand Down

0 comments on commit 413949e

Please sign in to comment.