mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-09 13:39:30 +01:00
31 lines
873 B
Dart
31 lines
873 B
Dart
import 'package:matrix/matrix.dart';
|
|
|
|
extension ClientPresenceExtension on Client {
|
|
List<CachedPresence> get contactList {
|
|
final directChatsMxid = rooms
|
|
.where((r) => r.isDirectChat)
|
|
.map((r) => r.directChatMatrixID)
|
|
.toSet();
|
|
final contactList = directChatsMxid
|
|
.map(
|
|
(mxid) =>
|
|
presences[mxid] ??
|
|
CachedPresence(
|
|
PresenceType.offline,
|
|
0,
|
|
null,
|
|
false,
|
|
mxid ?? '',
|
|
),
|
|
)
|
|
.toList();
|
|
|
|
contactList.sort((a, b) => a.userid.compareTo(b.userid));
|
|
contactList.sort((a, b) => ((a.lastActiveTimestamp ??
|
|
DateTime.fromMillisecondsSinceEpoch(0))
|
|
.compareTo(
|
|
b.lastActiveTimestamp ?? DateTime.fromMillisecondsSinceEpoch(0))));
|
|
return contactList;
|
|
}
|
|
}
|