From 8db656e699958812bd9ecf13e811d6e785f365c4 Mon Sep 17 00:00:00 2001 From: Eldar2021 Date: Sat, 13 Jul 2024 00:38:42 +0600 Subject: [PATCH] Deleted unused params token --- .../hatim/data/repository/hatim_read_repository_impl.dart | 4 ++-- .../hatim/data/source/hatim_remote_data_source.dart | 2 +- .../hatim/domain/repository/hatim_read_repository.dart | 2 +- app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart | 2 +- .../modules/home/data/repository/home_repository_impl.dart | 4 ++-- .../modules/home/data/source/home_remote_data_source.dart | 2 +- .../modules/home/domain/repository/home_repository.dart | 2 +- app/lib/modules/home/domain/usecase/get_data_usecase.dart | 4 ++-- app/lib/modules/home/presentation/cubit/home_cubit.dart | 4 ++-- app/lib/modules/home/presentation/view/home_view.dart | 7 ++----- app/test/mocks/app_mocks.dart | 2 +- 11 files changed, 16 insertions(+), 19 deletions(-) diff --git a/app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart b/app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart index dda03e48..690c2663 100644 --- a/app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart +++ b/app/lib/modules/hatim/data/repository/hatim_read_repository_impl.dart @@ -11,8 +11,8 @@ final class HatimReadRepositoryImpl implements HatimRepository { final HatimRemoteDataSource dataSource; @override - Future getHatim(String token) async { - final res = await dataSource.getHatim(token); + Future getHatim() async { + final res = await dataSource.getHatim(); return res.toEntity; } diff --git a/app/lib/modules/hatim/data/source/hatim_remote_data_source.dart b/app/lib/modules/hatim/data/source/hatim_remote_data_source.dart index 49a5beeb..8c14b38f 100644 --- a/app/lib/modules/hatim/data/source/hatim_remote_data_source.dart +++ b/app/lib/modules/hatim/data/source/hatim_remote_data_source.dart @@ -16,7 +16,7 @@ class HatimRemoteDataSource { late final WebSocketChannel channel; bool isInitilized = false; - Future getHatim(String token) async { + Future getHatim() async { try { final res = await remoteClient.postType( apiConst.joinToHatim, diff --git a/app/lib/modules/hatim/domain/repository/hatim_read_repository.dart b/app/lib/modules/hatim/domain/repository/hatim_read_repository.dart index c4bccd2b..9d7796e8 100644 --- a/app/lib/modules/hatim/domain/repository/hatim_read_repository.dart +++ b/app/lib/modules/hatim/domain/repository/hatim_read_repository.dart @@ -1,7 +1,7 @@ import 'package:my_quran/modules/modules.dart'; abstract class HatimRepository { - Future getHatim(String token); + Future getHatim(); void connectToSocket(String token); diff --git a/app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart b/app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart index 097f20ca..9f6a9828 100644 --- a/app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart +++ b/app/lib/modules/hatim/presentation/bloc/hatim_bloc.dart @@ -40,7 +40,7 @@ class HatimBloc extends Bloc { try { if (state.dashBoardState is HatimDashBoardLoading) return; emit(state.copyWith(dashBoardState: const HatimDashBoardLoading())); - final data = await repo.getHatim(token); + final data = await repo.getHatim(); emit(state.copyWith(dashBoardState: HatimDashBoardFetched(data))); emit(state.copyWith(eventState: const HatimStateLoading())); diff --git a/app/lib/modules/home/data/repository/home_repository_impl.dart b/app/lib/modules/home/data/repository/home_repository_impl.dart index 21b0a7f2..8c6df6fd 100644 --- a/app/lib/modules/home/data/repository/home_repository_impl.dart +++ b/app/lib/modules/home/data/repository/home_repository_impl.dart @@ -15,9 +15,9 @@ final class HomeRepositoryImpl implements HomeRepository { final HomeRemoteDataSource remoteDataSource; @override - Future getData(String token) async { + Future getData() async { try { - final remoteData = await remoteDataSource.getRemoteData(token); + final remoteData = await remoteDataSource.getRemoteData(); await localDataSource.saveLocalData(remoteData); return _convertData(remoteData); } catch (e, s) { diff --git a/app/lib/modules/home/data/source/home_remote_data_source.dart b/app/lib/modules/home/data/source/home_remote_data_source.dart index bdd2eb91..95fcb8b8 100644 --- a/app/lib/modules/home/data/source/home_remote_data_source.dart +++ b/app/lib/modules/home/data/source/home_remote_data_source.dart @@ -9,7 +9,7 @@ final class HomeRemoteDataSource { final MqDio remoteClient; - Future getRemoteData(String token) async { + Future getRemoteData() async { final remoteValue = await remoteClient.getType( apiConst.hatimDashBoard, fromJson: HomeModelResponse.fromJson, diff --git a/app/lib/modules/home/domain/repository/home_repository.dart b/app/lib/modules/home/domain/repository/home_repository.dart index 05ba36f0..637e50ac 100644 --- a/app/lib/modules/home/domain/repository/home_repository.dart +++ b/app/lib/modules/home/domain/repository/home_repository.dart @@ -1,5 +1,5 @@ import 'package:my_quran/modules/modules.dart'; abstract class HomeRepository { - Future getData(String token); + Future getData(); } diff --git a/app/lib/modules/home/domain/usecase/get_data_usecase.dart b/app/lib/modules/home/domain/usecase/get_data_usecase.dart index 7aed328f..64968e36 100644 --- a/app/lib/modules/home/domain/usecase/get_data_usecase.dart +++ b/app/lib/modules/home/domain/usecase/get_data_usecase.dart @@ -7,7 +7,7 @@ final class GetHomeDataUseCase { final HomeRepository repository; - Future execute(String token) { - return repository.getData(token); + Future execute() { + return repository.getData(); } } diff --git a/app/lib/modules/home/presentation/cubit/home_cubit.dart b/app/lib/modules/home/presentation/cubit/home_cubit.dart index 6bc205d7..b6f67f71 100644 --- a/app/lib/modules/home/presentation/cubit/home_cubit.dart +++ b/app/lib/modules/home/presentation/cubit/home_cubit.dart @@ -11,9 +11,9 @@ class HomeCubit extends Cubit { final GetHomeDataUseCase getHomeDataUseCase; - Future getData(String token) async { + Future getData() async { try { - final homeModel = await getHomeDataUseCase.execute(token); + final homeModel = await getHomeDataUseCase.execute(); emit(HomeState(status: FetchStatus.success, homeModel: homeModel)); } catch (e, s) { MqCrashlytics.report(e, s); diff --git a/app/lib/modules/home/presentation/view/home_view.dart b/app/lib/modules/home/presentation/view/home_view.dart index fb6df8ee..4a4dc211 100644 --- a/app/lib/modules/home/presentation/view/home_view.dart +++ b/app/lib/modules/home/presentation/view/home_view.dart @@ -28,7 +28,7 @@ class _HomeViewState extends State { if (homeCubit.state.status != FetchStatus.success && user != null) { MqCrashlytics.setUserIdentifier(validName ?? user.accessToken); MqAnalytic.setUserProperty(validName ?? user.accessToken); - homeCubit.getData(user.accessToken); + homeCubit.getData(); } super.initState(); } @@ -42,10 +42,7 @@ class _HomeViewState extends State { body: RefreshIndicator( onRefresh: () async { MqAnalytic.track(AnalyticKey.refreshHomePage); - final user = context.read().state.user; - if (user != null) { - await context.read().getData(user.accessToken); - } + await context.read().getData(); }, child: SafeArea( child: ListView( diff --git a/app/test/mocks/app_mocks.dart b/app/test/mocks/app_mocks.dart index d75470e1..f0660677 100644 --- a/app/test/mocks/app_mocks.dart +++ b/app/test/mocks/app_mocks.dart @@ -22,7 +22,7 @@ final class MockPackageInfo extends Mock implements PackageInfo { final class MockHomeRepositoryImpl implements HomeRepository { @override - Future getData(String token) async { + Future getData() async { return const HomeEntity(allDoneHatims: 8, allDonePages: 5325, donePages: 634); } }