1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Display user posts

This commit is contained in:
2019-06-10 14:47:27 +02:00
parent f374215c0c
commit dd1a130436
3 changed files with 59 additions and 10 deletions

View File

@ -59,6 +59,28 @@ class PostsHelper {
}
}
/// Get the list of posts of a user
Future<PostsList> getUserPosts(int userID, {int from = 0}) async {
final response = await APIRequest(
uri: "posts/get_user",
needLogin: true,
args: {
"userID": userID.toString(),
"startFrom": from.toString()
}
).exec();
if (response.code != 200) return null;
try {
// Parse & return the list of posts
return PostsList()..addAll(response.getArray().map((f) => _apiToPost(f)));
} catch (e) {
print(e.toString());
return null;
}
}
/// Update a post content
Future<bool> updateContent(int id, String newContent) async {
return (await APIRequest(