user service update
This commit is contained in:
@@ -53,7 +53,7 @@ class _MihHomeState extends State<MihHome> {
|
||||
context.read<MzansiProfileProvider>();
|
||||
// Note: getUserData sets user and userProfilePicUrl in the provider
|
||||
if (mzansiProfileProvider.user == null) {
|
||||
await getUserData();
|
||||
await getUserData(mzansiProfileProvider);
|
||||
}
|
||||
// Note: getUserConsentStatus sets userConsent in the provider
|
||||
if (mzansiProfileProvider.userConsent == null) {
|
||||
@@ -177,12 +177,10 @@ class _MihHomeState extends State<MihHome> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getUserData() async {
|
||||
Future<void> getUserData(MzansiProfileProvider profileProvider) async {
|
||||
if (!mounted) return;
|
||||
String url;
|
||||
await MihUserServices().getMyUserDetails(
|
||||
context,
|
||||
);
|
||||
await MihUserServices().getMyUserDetails(profileProvider);
|
||||
if (!mounted) return;
|
||||
url = await MihFileApi.getMinioFileUrl(
|
||||
context.read<MzansiProfileProvider>().user!.pro_pic_path,
|
||||
|
||||
@@ -119,7 +119,7 @@ class MihUserServices {
|
||||
}
|
||||
|
||||
Future<AppUser?> getMyUserDetails(
|
||||
BuildContext context,
|
||||
MzansiProfileProvider profileProvider,
|
||||
) async {
|
||||
String app_id = await SuperTokens.getUserId();
|
||||
var response = await http.get(
|
||||
@@ -131,9 +131,9 @@ class MihUserServices {
|
||||
if (response.statusCode == 200) {
|
||||
String body = response.body;
|
||||
var jsonBody = jsonDecode(body);
|
||||
context.read<MzansiProfileProvider>().setUser(
|
||||
newUser: AppUser.fromJson(jsonBody),
|
||||
);
|
||||
profileProvider.setUser(
|
||||
newUser: AppUser.fromJson(jsonBody),
|
||||
);
|
||||
return AppUser.fromJson(jsonBody);
|
||||
} else {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user