Fix ChangeProfile block
This commit is contained in:
@@ -123,12 +123,18 @@ class AppController {
|
||||
);
|
||||
}
|
||||
|
||||
applyProfile() {
|
||||
globalState.applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
}
|
||||
|
||||
changeProfile(String? value) async {
|
||||
if (value == config.currentProfileId) return;
|
||||
config.currentProfileId = value;
|
||||
await updateClashConfig(isPatch: false);
|
||||
await updateGroups();
|
||||
changeProxy();
|
||||
await applyProfile();
|
||||
appState.delayMap = {};
|
||||
saveConfigPreferences();
|
||||
}
|
||||
@@ -142,10 +148,7 @@ class AppController {
|
||||
)
|
||||
.isBeforeNow();
|
||||
if (isNotNeedUpdate == false) continue;
|
||||
final result = await profile.update();
|
||||
if (result.type == ResultType.error) continue;
|
||||
await updateGroups();
|
||||
changeProxy();
|
||||
await profile.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'dart:io';
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:fl_clash/clash/clash.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/clash_config.dart';
|
||||
import 'package:fl_clash/plugins/app.dart';
|
||||
import 'package:fl_clash/widgets/scaffold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -88,6 +87,24 @@ class GlobalState {
|
||||
updateCurrentDelayDebounce!([proxyName]);
|
||||
}
|
||||
|
||||
applyProfile({
|
||||
required AppState appState,
|
||||
required Config config,
|
||||
required ClashConfig clashConfig,
|
||||
}) async {
|
||||
await updateClashConfig(
|
||||
clashConfig: clashConfig,
|
||||
config: config,
|
||||
isPatch: false,
|
||||
);
|
||||
await updateGroups(appState);
|
||||
changeProxy(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
}
|
||||
|
||||
init({
|
||||
required AppState appState,
|
||||
required Config config,
|
||||
@@ -101,18 +118,12 @@ class GlobalState {
|
||||
);
|
||||
}
|
||||
if (!appState.isInit) return;
|
||||
await updateClashConfig(
|
||||
clashConfig: clashConfig,
|
||||
config: config,
|
||||
isPatch: false,
|
||||
);
|
||||
updateGroups(appState);
|
||||
updateCoreVersionInfo(appState);
|
||||
changeProxy(
|
||||
await applyProfile(
|
||||
appState: appState,
|
||||
config: config,
|
||||
clashConfig: clashConfig,
|
||||
);
|
||||
updateCoreVersionInfo(appState);
|
||||
}
|
||||
|
||||
changeProxy({
|
||||
@@ -167,7 +178,7 @@ class GlobalState {
|
||||
}
|
||||
|
||||
Future<void> updateGroups(AppState appState) async {
|
||||
appState.groups = await clashCore.getProxiesGroups();
|
||||
appState.groups = await clashCore.getProxiesGroups();
|
||||
}
|
||||
|
||||
showMessage({
|
||||
|
||||
Reference in New Issue
Block a user