Add reconnect alert for config options
This commit is contained in:
@@ -16,6 +16,8 @@ import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
abstract interface class ConnectionRepository {
|
||||
SingboxConfigOption? get configOptionsSnapshot;
|
||||
|
||||
TaskEither<ConnectionFailure, Unit> setup();
|
||||
Stream<ConnectionStatus> watchConnectionStatus();
|
||||
TaskEither<ConnectionFailure, Unit> connect(
|
||||
@@ -50,6 +52,10 @@ class ConnectionRepositoryImpl
|
||||
final ProfilePathResolver profilePathResolver;
|
||||
final GeoAssetPathResolver geoAssetPathResolver;
|
||||
|
||||
SingboxConfigOption? _configOptionsSnapshot;
|
||||
@override
|
||||
SingboxConfigOption? get configOptionsSnapshot => _configOptionsSnapshot;
|
||||
|
||||
bool _initialized = false;
|
||||
|
||||
@override
|
||||
@@ -112,6 +118,7 @@ class ConnectionRepositoryImpl
|
||||
) {
|
||||
return exceptionHandler(
|
||||
() {
|
||||
_configOptionsSnapshot = options;
|
||||
return singbox
|
||||
.changeOptions(options)
|
||||
.mapLeft(InvalidConfigOption.new)
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/notification/in_app_notification_controller.dart';
|
||||
import 'package:hiddify/features/config_option/notifier/config_option_notifier.dart';
|
||||
import 'package:hiddify/features/connection/notifier/connection_notifier.dart';
|
||||
import 'package:hiddify/features/profile/notifier/active_profile_notifier.dart';
|
||||
import 'package:hiddify/utils/custom_loggers.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
@@ -19,6 +23,21 @@ class _ConnectionWrapperState extends ConsumerState<ConnectionWrapper>
|
||||
Widget build(BuildContext context) {
|
||||
ref.listen(connectionNotifierProvider, (_, __) {});
|
||||
|
||||
ref.listen(configOptionNotifierProvider, (previous, next) {
|
||||
if (next case AsyncData(value: true)) {
|
||||
final t = ref.read(translationsProvider);
|
||||
ref.watch(inAppNotificationControllerProvider).showActionToast(
|
||||
t.settings.config.reconnectMsg,
|
||||
actionText: t.settings.config.reconnectBtn,
|
||||
callback: () async {
|
||||
await ref
|
||||
.read(connectionNotifierProvider.notifier)
|
||||
.reconnect(await ref.read(activeProfileProvider.future));
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return widget.child;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user