mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Display the list of friends of the user
This commit is contained in:
38
lib/helpers/friends_helper.dart
Normal file
38
lib/helpers/friends_helper.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'package:comunic/lists/friends_list.dart';
|
||||
import 'package:comunic/models/api_request.dart';
|
||||
import 'package:comunic/models/friend.dart';
|
||||
|
||||
/// Friends helper
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class FriendsHelper {
|
||||
/// Get the list of friends of the user
|
||||
///
|
||||
/// Returns the list of friends in case of success, or null if an error
|
||||
/// occurred
|
||||
Future<FriendsList> downloadList() async {
|
||||
final response = await APIRequest(
|
||||
uri: "friends/getList",
|
||||
needLogin: true,
|
||||
args: {
|
||||
"complete": "true",
|
||||
},
|
||||
).exec();
|
||||
|
||||
if (response.code != 200) return null;
|
||||
|
||||
// Parse and return the list of friends
|
||||
FriendsList list = FriendsList();
|
||||
response.getArray().forEach((f) =>
|
||||
list.add(Friend(
|
||||
id: f["ID_friend"],
|
||||
accepted: f["accepted"] == 1,
|
||||
lastActive: f["time_last_activity"],
|
||||
following: f["following"] == 1,
|
||||
canPostTexts: f["canPostTexts"],),),
|
||||
);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user