2023-12-01 12:56:24 +03:30
|
|
|
import 'package:hiddify/core/preferences/general_preferences.dart';
|
2023-07-15 18:00:44 +03:30
|
|
|
import 'package:hiddify/features/common/window/window_controller.dart';
|
2023-12-01 12:56:24 +03:30
|
|
|
import 'package:hiddify/features/connection/notifier/connection_notifier.dart';
|
2023-11-26 21:20:58 +03:30
|
|
|
import 'package:hiddify/features/profile/notifier/profiles_update_notifier.dart';
|
2023-11-01 22:02:13 +03:30
|
|
|
import 'package:hiddify/features/system_tray/system_tray_controller.dart';
|
2023-07-15 18:00:44 +03:30
|
|
|
import 'package:hiddify/utils/platform_utils.dart';
|
|
|
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
|
|
|
|
|
|
part 'common_controllers.g.dart';
|
|
|
|
|
|
|
|
|
|
// this is a temporary solution to keep providers running even when there are no active listeners
|
|
|
|
|
// https://github.com/rrousselGit/riverpod/discussions/2730
|
|
|
|
|
@Riverpod(keepAlive: true)
|
|
|
|
|
void commonControllers(CommonControllersRef ref) {
|
2023-09-30 11:15:20 +03:30
|
|
|
ref.listen(
|
|
|
|
|
introCompletedProvider,
|
|
|
|
|
(_, completed) async {
|
|
|
|
|
if (completed) {
|
2023-11-26 21:20:58 +03:30
|
|
|
await ref.read(foregroundProfilesUpdateNotifierProvider.future);
|
2023-09-30 11:15:20 +03:30
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fireImmediately: true,
|
|
|
|
|
);
|
2023-07-15 18:00:44 +03:30
|
|
|
ref.listen(
|
2023-12-01 12:56:24 +03:30
|
|
|
connectionNotifierProvider,
|
2023-07-15 18:00:44 +03:30
|
|
|
(previous, next) {},
|
|
|
|
|
fireImmediately: true,
|
|
|
|
|
);
|
|
|
|
|
if (PlatformUtils.isDesktop) {
|
|
|
|
|
ref.listen(
|
|
|
|
|
windowControllerProvider,
|
|
|
|
|
(previous, next) {},
|
|
|
|
|
fireImmediately: true,
|
|
|
|
|
);
|
|
|
|
|
ref.listen(
|
|
|
|
|
systemTrayControllerProvider,
|
|
|
|
|
(previous, next) {},
|
|
|
|
|
fireImmediately: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|