fluffychat/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 09:30:03 +02:00
final statusList = presences.values.toList().reversed.toList();
2020-06-18 13:39:24 +02:00
final directRooms = rooms.where((r) => r.isDirectChat).toList();
statusList.removeWhere((p) =>
directRooms.indexWhere((r) => r.directChatMatrixID == p.senderId) ==
-1);
2020-05-09 09:30:03 +02:00
statusList.reversed.toList();
return statusList;
}
2020-06-18 13:39:24 +02:00
static final Map<String, Profile> presencesCache = {};
Future<Profile> requestProfileCached(String senderId) async {
presencesCache[senderId] ??= await getProfileFromUserId(senderId);
return presencesCache[senderId];
}
}