просмотр аватарок

This commit is contained in:
Jganenokk
2026-07-05 23:05:45 +07:00
parent 536eea26bd
commit 7ce7cf7a1d
6 changed files with 503 additions and 24 deletions
+29
View File
@@ -62,6 +62,15 @@ class PhoneLookupResult {
const PhoneLookupResult({required this.id, this.name, this.avatarUrl});
}
class ContactPhotos {
final List<String> urls;
final int total;
const ContactPhotos({required this.urls, required this.total});
static const empty = ContactPhotos(urls: [], total: 0);
}
class ContactsModule {
static final ValueNotifier<int> revision = ValueNotifier<int>(0);
@@ -194,6 +203,26 @@ class ContactsModule {
}
}
static Future<ContactPhotos> fetchPhotos(
Api api,
int contactId, {
int from = 0,
int count = 25,
}) async {
final map = await api.sendRequestMap(Opcode.contactPhotos, {
'contactId': contactId,
'from': from,
'count': count,
});
if (map == null) return ContactPhotos.empty;
final rawUrls = map['urls'];
final urls = rawUrls is List
? rawUrls.whereType<String>().toList()
: <String>[];
final total = map['total'] is int ? map['total'] as int : urls.length;
return ContactPhotos(urls: urls, total: total);
}
static Future<List<CachedContact>> getContacts(int accountId) async {
final rows = await AppDatabase.loadContacts(accountId);
return rows.map(CachedContact.fromDbRow).toList();