Skip to content

Commit

Permalink
Merge pull request #847 from bounswe/Bugfix/MB/841/last-activities-bu…
Browse files Browse the repository at this point in the history
…g-mobile

#841 resolved last activities bug in mobile app
  • Loading branch information
senaal authored Dec 25, 2023
2 parents 35e5b57 + 9ebb292 commit 3865b52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ludos/mobile/lib/user_profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
void initState() {
super.initState();
loadUserData();
retrieveUserID();
// retrieveUserID();
fetchLastActivities();
}

Expand Down Expand Up @@ -63,12 +63,14 @@ class _UserProfilePageState extends State<UserProfilePage> {
}
}

Future<void> retrieveUserID() async {

Future<void> fetchLastActivities() async {
try {
var response =
await apiService.search(widget.userProvider.token, widget.id!);
await apiService.search(widget.userProvider.token, widget.id!);
if (response.statusCode == 200) {
userData = json.decode(response.body);
//print(userData['users']);
for (var i = 0; i < userData['users'].length; i++) {
if (userData['users'][i]['username'] == widget.id) {
userData = userData['users'][i];
Expand All @@ -87,9 +89,6 @@ class _UserProfilePageState extends State<UserProfilePage> {
} catch (e) {
print('Error loading user data: $e');
}
}

Future<void> fetchLastActivities() async {
final response = await apiService.lastActivities(
widget.userProvider.token,
limit: 5,
Expand All @@ -98,7 +97,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
try {
if (response.statusCode == 200) {
final Map<String, dynamic> responseData = json.decode(response.body);
//print(responseData);
// print(responseData);
for (var i = 0; i < responseData["items"].length; i++) {
if (responseData["items"][i]['user']['id'] == userID) {
setState(() {
Expand Down
5 changes: 5 additions & 0 deletions ludos/mobile/lib/visit_user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class _VisitUserPageState extends State<VisitUserPage> {
});
}
}
/*
for (var i = 0; i < lastActivities!.length; i++) {
print(lastActivities![i]);
}
*/
} else {
print("Error: ${response.statusCode} - ${response.body}");
throw Exception('Failed to load posts');
Expand Down

0 comments on commit 3865b52

Please sign in to comment.