2026-01-17 13:09:20 +03:00
|
|
|
import 'package:umbrix/core/database/database_provider.dart';
|
|
|
|
|
import 'package:umbrix/core/directories/directories_provider.dart';
|
|
|
|
|
import 'package:umbrix/core/http_client/http_client_provider.dart';
|
|
|
|
|
import 'package:umbrix/features/config_option/data/config_option_data_providers.dart';
|
|
|
|
|
import 'package:umbrix/features/profile/data/profile_data_source.dart';
|
|
|
|
|
import 'package:umbrix/features/profile/data/profile_path_resolver.dart';
|
|
|
|
|
import 'package:umbrix/features/profile/data/profile_repository.dart';
|
|
|
|
|
import 'package:umbrix/singbox/service/singbox_service_provider.dart';
|
2023-11-26 21:20:58 +03:30
|
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
|
|
|
|
|
|
part 'profile_data_providers.g.dart';
|
|
|
|
|
|
|
|
|
|
@Riverpod(keepAlive: true)
|
|
|
|
|
Future<ProfileRepository> profileRepository(ProfileRepositoryRef ref) async {
|
|
|
|
|
final repo = ProfileRepositoryImpl(
|
|
|
|
|
profileDataSource: ref.watch(profileDataSourceProvider),
|
|
|
|
|
profilePathResolver: ref.watch(profilePathResolverProvider),
|
2023-12-01 12:56:24 +03:30
|
|
|
singbox: ref.watch(singboxServiceProvider),
|
2024-07-30 08:07:46 +02:00
|
|
|
configOptionRepository: ref.watch(configOptionRepositoryProvider),
|
2024-01-03 21:15:55 +03:30
|
|
|
httpClient: ref.watch(httpClientProvider),
|
2023-11-26 21:20:58 +03:30
|
|
|
);
|
|
|
|
|
await repo.init().getOrElse((l) => throw l).run();
|
|
|
|
|
return repo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Riverpod(keepAlive: true)
|
|
|
|
|
ProfileDataSource profileDataSource(ProfileDataSourceRef ref) {
|
|
|
|
|
return ProfileDao(ref.watch(appDatabaseProvider));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Riverpod(keepAlive: true)
|
|
|
|
|
ProfilePathResolver profilePathResolver(ProfilePathResolverRef ref) {
|
|
|
|
|
return ProfilePathResolver(
|
2023-12-22 14:16:24 +03:30
|
|
|
ref.watch(appDirectoriesProvider).requireValue.workingDir,
|
2023-11-26 21:20:58 +03:30
|
|
|
);
|
|
|
|
|
}
|