fetchProfileInfo method

  1. @override
Future<void> fetchProfileInfo()
override

Implementation

@override
Future<void> fetchProfileInfo() async {
  AppConfig.logger.d('fetchProfileInfo');

  final profileBox = await getBox(AppHiveBox.profile.name);
  userServiceImpl.user.id = profileBox.get(AppHiveConstants.userId, defaultValue: '');
  userServiceImpl.user.name = profileBox.get(AppHiveConstants.username, defaultValue: '');
  userServiceImpl.profile.id = profileBox.get(AppHiveConstants.profileId, defaultValue: '');
  userServiceImpl.profile.aboutMe = profileBox.get(AppHiveConstants.aboutMe, defaultValue: '');
  userServiceImpl.profile.photoUrl = profileBox.get(AppHiveConstants.photoUrl, defaultValue: '');
  firstTime = profileBox.get(AppHiveConstants.firstTime, defaultValue: false);
  lastNotificationCheckDate = profileBox.get(AppHiveConstants.lastNotificationCheckDate, defaultValue: 0);

  await userServiceImpl.getProfiles();

  final savedLocale = profileBox.get(AppHiveConstants.appLocale, defaultValue: 'spanish');
  if(savedLocale.isNotEmpty) {
    setLocale(EnumToString.fromString(AppLocale.values, savedLocale)!);
  } else {
    AppLocale appLocale = AppLocale.spanish;

    switch(Get.locale?.languageCode ?? "") {
      case "es":
        appLocale = AppLocale.spanish;
        break;
      case "en":
        appLocale = AppLocale.english;
        break;
      case "":
        break;

    }
    setLocale(appLocale);
    updateLocale(appLocale);
  }

}