Fix bootstrap bug
This commit is contained in:
@@ -94,13 +94,32 @@ Future<void> _lazyBootstrap(
|
|||||||
if (silentStart) {
|
if (silentStart) {
|
||||||
FlutterNativeSplash.remove();
|
FlutterNativeSplash.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlatformUtils.isDesktop) {
|
if (PlatformUtils.isDesktop) {
|
||||||
|
_logger.debug("initializing [Auto Start Service] and [Window Controller]");
|
||||||
await container.read(autoStartServiceProvider.future);
|
await container.read(autoStartServiceProvider.future);
|
||||||
await container.read(windowControllerProvider.future);
|
await container.read(windowControllerProvider.future);
|
||||||
}
|
}
|
||||||
|
|
||||||
await initAppServices(container.read);
|
await container.read(singboxServiceProvider).init();
|
||||||
await initControllers(container.read);
|
_logger.debug("initialized [Singbox Service]");
|
||||||
|
|
||||||
|
await container.read(activeProfileProvider.future);
|
||||||
|
await container.read(deepLinkServiceProvider.future);
|
||||||
|
if (PlatformUtils.isDesktop) {
|
||||||
|
try {
|
||||||
|
await container
|
||||||
|
.read(systemTrayControllerProvider.future)
|
||||||
|
.timeout(const Duration(seconds: 1));
|
||||||
|
_logger.debug("initialized [System Tray Controller]");
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
_logger.warning(
|
||||||
|
"error initializing [System Tray Controller]",
|
||||||
|
error,
|
||||||
|
stackTrace,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
ProviderScope(
|
ProviderScope(
|
||||||
@@ -130,29 +149,3 @@ void initLoggers(
|
|||||||
logOptions: LogOptions(logLevel),
|
logOptions: LogOptions(logLevel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initAppServices(
|
|
||||||
Result Function<Result>(ProviderListenable<Result>) read,
|
|
||||||
) async {
|
|
||||||
_logger.debug("initializing app services");
|
|
||||||
await Future.wait(
|
|
||||||
[
|
|
||||||
read(singboxServiceProvider).init(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
_logger.debug('initialized app services');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> initControllers(
|
|
||||||
Result Function<Result>(ProviderListenable<Result>) read,
|
|
||||||
) async {
|
|
||||||
_logger.debug("initializing controllers");
|
|
||||||
await Future.wait(
|
|
||||||
[
|
|
||||||
read(activeProfileProvider.future),
|
|
||||||
read(deepLinkServiceProvider.future),
|
|
||||||
if (PlatformUtils.isDesktop) read(systemTrayControllerProvider.future),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
_logger.debug("initialized base controllers");
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -90,8 +90,9 @@ class ConnectivityController extends _$ConnectivityController with AppLogger {
|
|||||||
final activeProfile = await ref.read(activeProfileProvider.future);
|
final activeProfile = await ref.read(activeProfileProvider.future);
|
||||||
await _core
|
await _core
|
||||||
.start(activeProfile!.id, ref.read(disableMemoryLimitProvider))
|
.start(activeProfile!.id, ref.read(disableMemoryLimitProvider))
|
||||||
.mapLeft((err) {
|
.mapLeft((err) async {
|
||||||
loggy.warning("error connecting $err", err);
|
loggy.warning("error connecting", err);
|
||||||
|
await ref.read(startedByUserProvider.notifier).update(false);
|
||||||
state = AsyncError(err, StackTrace.current);
|
state = AsyncError(err, StackTrace.current);
|
||||||
}).run();
|
}).run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class WindowController extends _$WindowController
|
|||||||
await windowManager.hide();
|
await windowManager.hide();
|
||||||
}
|
}
|
||||||
await Future.delayed(
|
await Future.delayed(
|
||||||
const Duration(seconds: 1),
|
const Duration(seconds: 3),
|
||||||
() async {
|
() async {
|
||||||
if (ref.read(startedByUserProvider)) {
|
if (ref.read(startedByUserProvider)) {
|
||||||
loggy.debug("previously started by user, trying to connect");
|
loggy.debug("previously started by user, trying to connect");
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ class SystemTrayController extends _$SystemTrayController
|
|||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final connection = await ref.watch(connectivityControllerProvider.future);
|
final connection = switch (ref.watch(connectivityControllerProvider)) {
|
||||||
|
AsyncData(:final value) => value,
|
||||||
|
_ => const Disconnected(),
|
||||||
|
};
|
||||||
final serviceMode = ref.watch(serviceModeStoreProvider);
|
final serviceMode = ref.watch(serviceModeStoreProvider);
|
||||||
|
|
||||||
final t = ref.watch(translationsProvider);
|
final t = ref.watch(translationsProvider);
|
||||||
|
|||||||
Reference in New Issue
Block a user