feat : change app inspector and exception handling

This commit is contained in:
2025-07-12 17:06:29 +03:30
parent e52674de37
commit 0fc16569a6
24 changed files with 472 additions and 322 deletions

View File

@@ -9,7 +9,7 @@ import '../common/dio_manager.dart';
GetIt diAuth = GetIt.instance;
Future<void> setupAuthDI() async {
diAuth.registerLazySingleton(() => DioRemoteManager());
diAuth.registerLazySingleton<AppInterceptor>(
() => AppInterceptor(
refreshTokenCallback: () async {
@@ -19,7 +19,9 @@ Future<void> setupAuthDI() async {
final refreshToken = tokenService.refreshToken.value;
if (refreshToken == null) return null;
final result = await authRepo.loginWithRefreshToken(authRequest: {"refresh_token": refreshToken});
final result = await authRepo.loginWithRefreshToken(
authRequest: {"refresh_token": refreshToken},
);
if (result is AuthResponseModel) {
await tokenService.saveAccessToken(result.access!);
@@ -27,10 +29,18 @@ Future<void> setupAuthDI() async {
}
return null;
},
saveTokenCallback: (String newToken) async {
//
},
clearTokenCallback: () async {
//await tokenService.clearTokens(); // حذف همه توکن‌ها
},
),
);
diAuth.registerLazySingleton<DioRemote>(() => DioRemote(interceptors: [diAuth.get<AppInterceptor>()]));
diAuth.registerLazySingleton<DioRemote>(
() => DioRemote(interceptors: diAuth.get<AppInterceptor>()),
);
final dioRemote = diAuth.get<DioRemote>();
await dioRemote.init();
@@ -40,10 +50,13 @@ Future<void> setupAuthDI() async {
Future<void> newSetupAuthDI(String newUrl) async {
diAuth.registerLazySingleton<DioRemote>(
() => DioRemote(baseUrl: newUrl, interceptors: [diAuth.get<AppInterceptor>()]),
() => DioRemote(baseUrl: newUrl, interceptors: diAuth.get<AppInterceptor>()),
instanceName: 'newRemote',
);
final dioRemote = diAuth.get<DioRemote>(instanceName: 'newRemote');
await dioRemote.init();
diAuth.registerSingleton<AuthRepositoryImpl>(AuthRepositoryImpl(dioRemote), instanceName: 'newUrl');
diAuth.registerSingleton<AuthRepositoryImpl>(
AuthRepositoryImpl(dioRemote),
instanceName: 'newUrl',
);
}