|
|
|
|
@ -33,6 +33,7 @@ import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_mode
|
|
|
|
|
import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/symptoms_checker/symptoms_checker_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/authentication/login.dart';
|
|
|
|
|
@ -52,7 +53,6 @@ import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
|
|
|
|
import 'package:sms_otp_auto_verify/sms_otp_auto_verify.dart';
|
|
|
|
|
|
|
|
|
|
import '../insurance/insurance_view_model.dart';
|
|
|
|
|
import '../profile_settings/profile_settings_repo.dart';
|
|
|
|
|
import 'models/request_models/get_user_mobile_device_data.dart';
|
|
|
|
|
import 'models/request_models/insert_patient_mobile_deviceinfo.dart';
|
|
|
|
|
import 'models/request_models/patient_insert_device_imei_request.dart';
|
|
|
|
|
@ -1824,6 +1824,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
_appState.setAppAuthToken = "";
|
|
|
|
|
_appState.setUserBloodGroup = "";
|
|
|
|
|
_appState.clearProfileImageCache(); // Clear profile image cache
|
|
|
|
|
GetIt.instance<ProfileSettingsViewModel>().clearProfileImageCache();
|
|
|
|
|
_appState.setSuperUserID = null;
|
|
|
|
|
_appState.setIsChildLoggedIn = false;
|
|
|
|
|
_appState.setFamilyFileTokenID = "";
|
|
|
|
|
@ -1877,43 +1878,16 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
try {
|
|
|
|
|
log("Fetching profile image for patient ID: $patientID");
|
|
|
|
|
|
|
|
|
|
// IMPORTANT: Clear old cache BEFORE fetching new image
|
|
|
|
|
// This ensures old data is removed immediately
|
|
|
|
|
// Clear old cache before fetching new image
|
|
|
|
|
_appState.clearProfileImageCache();
|
|
|
|
|
log("🧹 Cleared profile image cache before fetch");
|
|
|
|
|
|
|
|
|
|
final profileSettingsRepo = GetIt.instance<ProfileSettingsRepo>();
|
|
|
|
|
final result = await profileSettingsRepo.getProfileImage(patientID: patientID);
|
|
|
|
|
final profileSettingsVM = GetIt.instance<ProfileSettingsViewModel>();
|
|
|
|
|
profileSettingsVM.clearProfileImageCache();
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) {
|
|
|
|
|
// Silently fail - profile image is optional
|
|
|
|
|
log("Failed to fetch profile image: ${failure.message}");
|
|
|
|
|
// Ensure cache is cleared even on failure
|
|
|
|
|
_appState.setProfileImageData = null;
|
|
|
|
|
},
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
if (apiResponse.data != null && apiResponse.data['Patient_GetProfileImageDataList'] != null) {
|
|
|
|
|
var imageList = apiResponse.data['Patient_GetProfileImageDataList'];
|
|
|
|
|
if (imageList is List && imageList.isNotEmpty) {
|
|
|
|
|
String? imageData = imageList[0]['ImageData'];
|
|
|
|
|
if (imageData != null && imageData.isNotEmpty) {
|
|
|
|
|
// Set new profile image data - this will update cache and notify all listeners
|
|
|
|
|
_appState.setProfileImageData = imageData;
|
|
|
|
|
log("✅ Profile image loaded and cached successfully for patient: $patientID");
|
|
|
|
|
} else {
|
|
|
|
|
log("⚠️ Profile image data is empty for patient: $patientID");
|
|
|
|
|
_appState.setProfileImageData = null;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log("⚠️ Profile image list is empty for patient: $patientID");
|
|
|
|
|
_appState.setProfileImageData = null;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log("⚠️ No profile image data in response for patient: $patientID");
|
|
|
|
|
_appState.setProfileImageData = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
await profileSettingsVM.getProfileImage(
|
|
|
|
|
patientID: patientID,
|
|
|
|
|
forceRefresh: true,
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
log("❌ Error fetching profile image: $e");
|
|
|
|
|
|