feat : first step request tagging
This commit is contained in:
@@ -11,27 +11,17 @@ GetIt get diLiveStock => GetIt.instance;
|
||||
Future<void> setupLiveStockDI() async {
|
||||
diLiveStock.registerSingleton(DioErrorHandler());
|
||||
|
||||
|
||||
final tokenService = Get.find<TokenStorageService>();
|
||||
|
||||
|
||||
if (tokenService.baseurl.value == null) {
|
||||
await tokenService.saveBaseUrl('https://api.dam.rasadyar.net/');
|
||||
}
|
||||
|
||||
|
||||
diLiveStock.registerLazySingleton<AuthRemoteDataSource>(
|
||||
() => AuthRemoteDataSourceImp(diLiveStock.get<DioRemote>()),
|
||||
);
|
||||
|
||||
diLiveStock.registerLazySingleton<AuthRepository>(
|
||||
() => AuthRepositoryImp(diLiveStock.get<AuthRemoteDataSource>()),
|
||||
);
|
||||
|
||||
|
||||
// First register AppInterceptor with lazy callbacks
|
||||
diLiveStock.registerLazySingleton<AppInterceptor>(
|
||||
() => AppInterceptor(
|
||||
() => AppInterceptor(
|
||||
refreshTokenCallback: () async {
|
||||
// Use lazy access to avoid circular dependency
|
||||
final authRepository = diLiveStock.get<AuthRepository>();
|
||||
final hasAuthenticated = await authRepository.hasAuthenticated();
|
||||
if (hasAuthenticated) {
|
||||
@@ -53,13 +43,26 @@ Future<void> setupLiveStockDI() async {
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// Register DioRemote with the interceptor
|
||||
diLiveStock.registerLazySingleton<DioRemote>(
|
||||
() => DioRemote(
|
||||
() => DioRemote(
|
||||
baseUrl: tokenService.baseurl.value,
|
||||
interceptors: diLiveStock.get<AppInterceptor>(),
|
||||
// interceptors: diLiveStock.get<AppInterceptor>(),
|
||||
),
|
||||
);
|
||||
|
||||
// Initialize DioRemote
|
||||
await diLiveStock.get<DioRemote>().init();
|
||||
|
||||
// Now register the data source and repository
|
||||
diLiveStock.registerLazySingleton<AuthRemoteDataSource>(
|
||||
() => AuthRemoteDataSourceImp(diLiveStock.get<DioRemote>()),
|
||||
);
|
||||
|
||||
diLiveStock.registerLazySingleton<AuthRepository>(
|
||||
() => AuthRepositoryImp(diLiveStock.get<AuthRemoteDataSource>()),
|
||||
);
|
||||
|
||||
diLiveStock.registerLazySingleton<ImagePicker>(() => ImagePicker());
|
||||
await diLiveStock.allReady();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user