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