Remove reconnect on auto profile update
This commit is contained in:
@@ -24,3 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Localization mistakes in Russian from [solokot](https://github.com/solokot)
|
- Localization mistakes in Russian from [solokot](https://github.com/solokot)
|
||||||
- Localization mistakes in Russian from [Elshad Guseynov](https://github.com/lifeindarkside)
|
- Localization mistakes in Russian from [Elshad Guseynov](https://github.com/lifeindarkside)
|
||||||
- Logs filtering
|
- Logs filtering
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Reconnect on auto profile update
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ConnectivityController extends _$ConnectivityController with AppLogger {
|
|||||||
activeProfileProvider.select((value) => value.asData?.value),
|
activeProfileProvider.select((value) => value.asData?.value),
|
||||||
(previous, next) async {
|
(previous, next) async {
|
||||||
if (previous == null) return;
|
if (previous == null) return;
|
||||||
final shouldReconnect = previous != next;
|
final shouldReconnect = next == null || previous.id != next.id;
|
||||||
if (shouldReconnect) {
|
if (shouldReconnect) {
|
||||||
await reconnect(next?.id);
|
await reconnect(next?.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:hiddify/data/data_providers.dart';
|
|||||||
import 'package:hiddify/domain/enums.dart';
|
import 'package:hiddify/domain/enums.dart';
|
||||||
import 'package:hiddify/domain/profiles/profiles.dart';
|
import 'package:hiddify/domain/profiles/profiles.dart';
|
||||||
import 'package:hiddify/features/common/active_profile/active_profile_notifier.dart';
|
import 'package:hiddify/features/common/active_profile/active_profile_notifier.dart';
|
||||||
|
import 'package:hiddify/features/common/connectivity/connectivity_controller.dart';
|
||||||
import 'package:hiddify/utils/utils.dart';
|
import 'package:hiddify/utils/utils.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
@@ -86,15 +87,23 @@ class ProfilesNotifier extends _$ProfilesNotifier with AppLogger {
|
|||||||
|
|
||||||
Future<Unit?> updateProfile(RemoteProfile profile) async {
|
Future<Unit?> updateProfile(RemoteProfile profile) async {
|
||||||
loggy.debug("updating profile");
|
loggy.debug("updating profile");
|
||||||
return ref.read(profilesRepositoryProvider).update(profile).match(
|
return await ref.read(profilesRepositoryProvider).update(profile).match(
|
||||||
(err) {
|
(err) {
|
||||||
loggy.warning("failed to update profile", err);
|
loggy.warning("failed to update profile", err);
|
||||||
throw err;
|
throw err;
|
||||||
},
|
},
|
||||||
(_) {
|
(_) async {
|
||||||
loggy.info(
|
loggy.info(
|
||||||
'successfully updated profile, was active? [${profile.active}]',
|
'successfully updated profile, was active? [${profile.active}]',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await ref.read(activeProfileProvider.future).then((active) async {
|
||||||
|
if (active != null && active.id == profile.id) {
|
||||||
|
await ref
|
||||||
|
.read(connectivityControllerProvider.notifier)
|
||||||
|
.reconnect(profile.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
return unit;
|
return unit;
|
||||||
},
|
},
|
||||||
).run();
|
).run();
|
||||||
|
|||||||
Reference in New Issue
Block a user