mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
search users
This commit is contained in:
@@ -309,3 +309,36 @@ class SearchOptions {
|
||||
DateTime? endTime;
|
||||
AgeLimit ageLimit = AgeLimit.unlimited;
|
||||
}
|
||||
|
||||
/*
|
||||
json:
|
||||
{
|
||||
"id": 20542044,
|
||||
"name": "vocaloidhm01",
|
||||
"account": "vocaloidhm01",
|
||||
"profile_image_urls": {
|
||||
"medium": "https://i.pximg.net/user-profile/img/2023/04/28/00/21/54/24348957_c74a61e78ddccb467417be7c37b5d463_170.jpg"
|
||||
},
|
||||
"is_followed": false,
|
||||
"is_access_blocking_user": false
|
||||
}
|
||||
*/
|
||||
class UserPreview {
|
||||
final int id;
|
||||
final String name;
|
||||
final String account;
|
||||
final String avatar;
|
||||
bool isFollowed;
|
||||
final bool isBlocking;
|
||||
|
||||
UserPreview(this.id, this.name, this.account, this.avatar, this.isFollowed,
|
||||
this.isBlocking);
|
||||
|
||||
UserPreview.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'],
|
||||
name = json['name'],
|
||||
account = json['account'],
|
||||
avatar = json['profile_image_urls']['medium'],
|
||||
isFollowed = json['is_followed'],
|
||||
isBlocking = json['is_access_blocking_user'];
|
||||
}
|
||||
|
@@ -302,12 +302,12 @@ class Network {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Res<List<User>>> searchUsers(String keyword, [String? nextUrl]) async{
|
||||
Future<Res<List<UserPreview>>> searchUsers(String keyword, [String? nextUrl]) async{
|
||||
var path = nextUrl ?? "/v1/search/user?filter=for_android&word=${Uri.encodeComponent(keyword)}";
|
||||
var res = await apiGet(path);
|
||||
if (res.success) {
|
||||
return Res(
|
||||
(res.data["user_previews"] as List).map((e) => User.fromJson(e)).toList(),
|
||||
(res.data["user_previews"] as List).map((e) => UserPreview.fromJson(e["user"])).toList(),
|
||||
subData: res.data["next_url"]);
|
||||
} else {
|
||||
return Res.error(res.errorMessage);
|
||||
|
Reference in New Issue
Block a user