You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
888 B
Dart
30 lines
888 B
Dart
5 years ago
|
import 'package:famedlysdk/famedlysdk.dart';
|
||
|
|
||
|
extension ClientPresenceExtension on Client {
|
||
4 years ago
|
List<Presence> get contactList {
|
||
|
final directChatsMxid = rooms
|
||
|
.where((r) => r.isDirectChat)
|
||
|
.map((r) => r.directChatMatrixID)
|
||
|
.toSet();
|
||
|
final contactList = directChatsMxid
|
||
|
.map(
|
||
|
(mxid) =>
|
||
|
presences[mxid] ??
|
||
|
Presence.fromJson(
|
||
|
{
|
||
|
'sender': mxid,
|
||
|
'type': 'm.presence',
|
||
4 years ago
|
'content': {'presence': 'offline'},
|
||
4 years ago
|
},
|
||
|
),
|
||
|
)
|
||
|
.toList();
|
||
4 years ago
|
|
||
|
contactList.sort((a, b) => a.senderId.compareTo(b.senderId));
|
||
4 years ago
|
contactList.sort((a, b) => (a.presence.lastActiveAgo?.toDouble() ??
|
||
|
double.infinity)
|
||
|
.compareTo((b.presence.lastActiveAgo?.toDouble() ?? double.infinity)));
|
||
|
return contactList;
|
||
|
}
|
||
5 years ago
|
}
|