From ef102bdf94205e1bfe9bb6f29d0b1883ef1b6ff4 Mon Sep 17 00:00:00 2001 From: dignow Date: Fri, 23 Jun 2023 14:29:58 +0800 Subject: [PATCH] debug, mobile, connection state Signed-off-by: dignow --- flutter/lib/mobile/pages/connection_page.dart | 3 --- flutter/lib/mobile/pages/server_page.dart | 1 - flutter/lib/models/server_model.dart | 4 +++- flutter/lib/models/state_model.dart | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/flutter/lib/mobile/pages/connection_page.dart b/flutter/lib/mobile/pages/connection_page.dart index df4a85233..5a581f0c7 100644 --- a/flutter/lib/mobile/pages/connection_page.dart +++ b/flutter/lib/mobile/pages/connection_page.dart @@ -11,7 +11,6 @@ import '../../common/widgets/login.dart'; import '../../common/widgets/peer_tab_page.dart'; import '../../consts.dart'; import '../../models/model.dart'; -import '../../models/state_model.dart'; import '../../models/platform_model.dart'; import 'home_page.dart'; import 'scan_page.dart'; @@ -55,7 +54,6 @@ class _ConnectionPageState extends State { } }(); } - stateGlobal.startSvcStatusTimer(); if (isAndroid) { Timer(const Duration(seconds: 5), () async { _updateUrl = await bind.mainGetSoftwareUpdateUrl(); @@ -182,7 +180,6 @@ class _ConnectionPageState extends State { @override void dispose() { _idController.dispose(); - stateGlobal.cancelSvcStatusTimer(); super.dispose(); } } diff --git a/flutter/lib/mobile/pages/server_page.dart b/flutter/lib/mobile/pages/server_page.dart index b79b5bdb2..0b0b8cc5c 100644 --- a/flutter/lib/mobile/pages/server_page.dart +++ b/flutter/lib/mobile/pages/server_page.dart @@ -201,7 +201,6 @@ class ServerInfo extends StatelessWidget { @override Widget build(BuildContext context) { final isPermanent = model.verificationMethod == kUsePermanentPassword; - final serverModel = Provider.of(context); const Color colorPositive = Colors.green; const Color colorNegative = Colors.red; diff --git a/flutter/lib/models/server_model.dart b/flutter/lib/models/server_model.dart index 765725537..4eddee2b6 100644 --- a/flutter/lib/models/server_model.dart +++ b/flutter/lib/models/server_model.dart @@ -15,7 +15,8 @@ import '../common/formatter/id_formatter.dart'; import '../desktop/pages/server_page.dart' as desktop; import '../desktop/widgets/tabbar_widget.dart'; import '../mobile/pages/server_page.dart'; -import 'model.dart'; +import './model.dart'; +import './state_model.dart'; const kLoginDialogTag = "LOGIN"; @@ -117,6 +118,7 @@ class ServerModel with ChangeNotifier { _serverId = IDTextEditingController(text: _emptyIdShow); timerCallback() async { + stateGlobal.updateSvcStatus(); if (desktopType == DesktopType.cm) { final res = await bind.cmCheckClientsLength(length: _clients.length); if (res != null) { diff --git a/flutter/lib/models/state_model.dart b/flutter/lib/models/state_model.dart index 2a457881d..842404ac2 100644 --- a/flutter/lib/models/state_model.dart +++ b/flutter/lib/models/state_model.dart @@ -95,7 +95,7 @@ class StateGlobal { startSvcStatusTimer() { _svcStatusTimer = periodic_immediate(Duration(seconds: 1), () async { - _updateSvcStatus(); + updateSvcStatus(); }); } @@ -104,7 +104,7 @@ class StateGlobal { _svcStatusTimer = null; } - _updateSvcStatus() async { + updateSvcStatus() async { final status = jsonDecode(await bind.mainGetConnectStatus()) as Map; final statusNum = status['status_num'] as int;