FurryChat/lib/utils/client_presence_extension.dart

21 lines
685 B
Dart
Raw Normal View History

import 'package:famedlysdk/famedlysdk.dart';
extension ClientPresenceExtension on Client {
List<Presence> get statusList {
2020-05-09 07:30:03 +00:00
final statusList = presences.values.toList().reversed.toList();
2020-06-18 11:39:24 +00:00
final directRooms = rooms.where((r) => r.isDirectChat).toList();
statusList.removeWhere((p) =>
directRooms.indexWhere((r) => r.directChatMatrixID == p.senderId) ==
-1);
2020-05-09 07:30:03 +00:00
statusList.reversed.toList();
return statusList;
}
2020-06-18 11:39:24 +00:00
static final Map<String, Profile> presencesCache = {};
Future<Profile> requestProfileCached(String senderId) async {
presencesCache[senderId] ??= await getProfileFromUserId(senderId);
return presencesCache[senderId];
}
}