diff --git a/core/common.go b/core/common.go index 4c00b11..98b9948 100644 --- a/core/common.go +++ b/core/common.go @@ -175,10 +175,8 @@ func patchConfig(general *config.General) { const concurrentCount = math.MaxInt -var wg = sync.WaitGroup{} -var exit = make(chan struct{}) - func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) { + wg := sync.WaitGroup{} ch := make(chan struct{}, concurrentCount) for _, proxyProvider := range proxyProviders { proxyProvider := proxyProvider @@ -186,11 +184,6 @@ func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) { log.Infoln("Start initial Compatible provider %s", proxyProvider.Name()) wg.Add(1) ch <- struct{}{} - select { - case <-exit: - return // 收到退出信号,退出协程 - default: - } go func() { defer func() { <-ch; wg.Done() }() if err := proxyProvider.Initial(); err != nil { @@ -202,13 +195,6 @@ func hcCompatibleProvider(proxyProviders map[string]provider.ProxyProvider) { } } -func cancelHc() { - close(exit) - wg.Wait() - exit = make(chan struct{}) - wg = sync.WaitGroup{} -} - func applyConfig(isPatch bool) { cfg, err := config.ParseRawConfig(currentConfig) if err != nil { diff --git a/lib/controller.dart b/lib/controller.dart index 1988854..0253c34 100644 --- a/lib/controller.dart +++ b/lib/controller.dart @@ -236,6 +236,7 @@ class AppController { } healthcheck() { + if (globalState.healthcheckLock) return; for (final delay in appState.delayMap.entries) { setDelay( Delay( diff --git a/lib/fragments/proxies.dart b/lib/fragments/proxies.dart index c7b6a47..e32832d 100644 --- a/lib/fragments/proxies.dart +++ b/lib/fragments/proxies.dart @@ -83,12 +83,15 @@ class _ProxiesFragmentState extends State groupNames: groupNames, ); }, - builder: (_, state, __) { - if (_tabController != null) { - _tabController!.dispose(); - _tabController = null; + shouldRebuild: (prev,next){ + if(prev.groupNames.length != next.groupNames.length){ + _tabController?.dispose(); + _tabController =null; } - _tabController = TabController( + return prev != next; + }, + builder: (_, state, __) { + _tabController ??= TabController( length: state.groupNames.length, vsync: this, initialIndex: state.currentIndex, @@ -118,7 +121,6 @@ class _ProxiesFragmentState extends State children: [ for (final groupName in state.groupNames) KeepContainer( - key: ObjectKey(groupName), child: ProxiesTabView( groupName: groupName, ), diff --git a/lib/state.dart b/lib/state.dart index 928601d..d2d39b0 100644 --- a/lib/state.dart +++ b/lib/state.dart @@ -23,6 +23,7 @@ class GlobalState { List updateFunctionLists = []; List currentNavigationItems = []; bool updatePackagesLock = false; + bool healthcheckLock = false; startListenUpdate() { if (timer != null && timer!.isActive == true) return; diff --git a/lib/widgets/clash_message_container.dart b/lib/widgets/clash_message_container.dart index d2c77af..d1478c3 100644 --- a/lib/widgets/clash_message_container.dart +++ b/lib/widgets/clash_message_container.dart @@ -38,12 +38,15 @@ class _ClashMessageContainerState extends State @override void onDelay(Delay delay) { - context.appController.setDelay(delay); + final appController = context.appController; + appController.setDelay(delay); + globalState.healthcheckLock = true; WidgetsBinding.instance.addPostFrameCallback((_) { globalState.updateSortNumDebounce ??= debounce( - () { - context.appController.updateGroups(); - context.appController.appState.sortNum++; + () async { + await appController.updateGroups(); + appController.appState.sortNum++; + globalState.healthcheckLock = false; }, milliseconds: 5000, ); diff --git a/pubspec.yaml b/pubspec.yaml index 28e164d..af1431c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fl_clash description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free. publish_to: 'none' -version: 0.7.12 +version: 0.7.13 environment: sdk: '>=3.1.0 <4.0.0'